public void PerformUpToDateCheck_WhenAProjectIsUnloaded_ItsWarningsAreNotReplayed() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); projectC.RestoreSettings.HideWarningsAndErrors = false; // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); var dgSpec = new DependencyGraphSpec(); dgSpec.AddProject(projectA); dgSpec.AddRestore(projectA.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectB); dgSpec.AddRestore(projectB.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectC); dgSpec.AddRestore(projectC.RestoreMetadata.ProjectUniqueName); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var testLogger = new TestLogger(); var actual = checker.PerformUpToDateCheck(dgSpec, testLogger); var expected = GetUniqueNames(projectA, projectB, projectC); actual.Should().BeEquivalentTo(expected); // ProjectC will have a warning var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>() { projectC.RestoreMetadata.ProjectUniqueName }, projectA, projectB, projectC); // The test logger will not contain any messages because we are not running actual restore. testLogger.WarningMessages.Should().BeEmpty(); checker.SaveRestoreStatus(results); // Run again to verify the warning is replayed once! testLogger = new TestLogger(); actual = checker.PerformUpToDateCheck(dgSpec, testLogger); testLogger.WarningMessages.Should().HaveCount(1); actual.Should().BeEmpty(); checker.SaveRestoreStatus(new RestoreSummary[] { }); // Pretend project C has been unloaded dgSpec = new DependencyGraphSpec(); dgSpec.AddProject(projectA); dgSpec.AddRestore(projectA.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectB); dgSpec.AddRestore(projectB.RestoreMetadata.ProjectUniqueName); // Act & Assert. testLogger = new TestLogger(); actual = checker.PerformUpToDateCheck(dgSpec, testLogger); testLogger.WarningMessages.Should().BeEmpty(); actual.Should().BeEmpty(); } }
public void PerformUpToDateCheck_LeafProjectChanges_ReturnsAllItsParents() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); var projectD = GetPackageSpec("D", testDirectory.Path); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); DependencyGraphSpec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC, projectD); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD); checker.SaveRestoreStatus(results); // Set-up, B => D projectB = projectB.WithTestProjectReference(projectD); dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD); // Act & Assert actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); expected = GetUniqueNames(projectA, projectB); actual.Should().BeEquivalentTo(expected); } }
public void PerformUpToDateCheck_WhenALeafProjectHasNoGlobalPackagesFolder_ReturnsOnlyThatProject() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); projectC.RestoreMetadata.PackagesPath = Path.Combine(testDirectory.Path, "gpf"); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); DependencyGraphSpec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC); checker.SaveRestoreStatus(results); // Set-up, delete C's outputs Directory.Delete(projectC.RestoreMetadata.PackagesPath, recursive: true); // Act & Assert actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); expected = GetUniqueNames(projectC); actual.Should().BeEquivalentTo(expected); } }
public void PerformUpToDateCheck_WithNoChanges_ReturnsEmpty() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); var dgSpec = new DependencyGraphSpec(); dgSpec.AddProject(projectA); dgSpec.AddRestore(projectA.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectB); dgSpec.AddRestore(projectB.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectC); dgSpec.AddRestore(projectC.RestoreMetadata.ProjectUniqueName); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC); checker.SaveRestoreStatus(results); // Act & Asset. actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); actual.Should().BeEmpty(); } }
public void PerformUpToDateCheck_WhenALeafProjectHasDirtyOutputs_ReturnsOnlyThatProject() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC); checker.SaveRestoreStatus(results); // Set-up, delete C's outputs SolutionUpToDateChecker.GetOutputFilePaths(projectC, out string assetsFilePath, out string _, out string _, out string _, out string _); File.Delete(assetsFilePath); // Act & Assert actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); expected = GetUniqueNames(projectC); actual.Should().BeEquivalentTo(expected); } }
public void ReportStatus_WhenPartialResultsAreAvailable_OldStatusIsRetained() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); var projectD = GetPackageSpec("D", testDirectory.Path); var projectE = GetPackageSpec("E", testDirectory.Path); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); // A => D projectA = projectA.WithTestProjectReference(projectD); DependencyGraphSpec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC, projectD, projectE); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD, projectE); checker.SaveRestoreStatus(results); // D => E projectD = projectD.WithTestProjectReference(projectE); // Set-up dg spec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE); // 2nd check actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); expected = GetUniqueNames(projectA, projectD); actual.Should().BeEquivalentTo(expected); results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectD); checker.SaveRestoreStatus(results); // Finally, last check. Run for a 3rd time. Everything should be up to date actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); expected = GetUniqueNames(); actual.Should().BeEquivalentTo(expected); } }
public void PerformUpToDateCheck_WithNoChanges_ReplaysWarningsForProjectsWithoutSuppressedWarnings() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); // Pretend C is a legacy package reference projects, so we manage it's error list. projectC.RestoreSettings = new ProjectRestoreSettings { HideWarningsAndErrors = false }; // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); var dgSpec = new DependencyGraphSpec(); dgSpec.AddProject(projectA); dgSpec.AddRestore(projectA.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectB); dgSpec.AddRestore(projectB.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectC); dgSpec.AddRestore(projectC.RestoreMetadata.ProjectUniqueName); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var testLogger = new TestLogger(); var actual = checker.PerformUpToDateCheck(dgSpec, testLogger); var expected = GetUniqueNames(projectA, projectB, projectC); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>() { projectC.RestoreMetadata.ProjectUniqueName }, projectA, projectB, projectC); // The test logger will not contain any messages because we are not running actual restore. testLogger.WarningMessages.Should().BeEmpty(); checker.SaveRestoreStatus(results); // Act & Asset. testLogger = new TestLogger(); actual = checker.PerformUpToDateCheck(dgSpec, testLogger); testLogger.WarningMessages.Should().HaveCount(1); actual.Should().BeEmpty(); } }
public void PerformUpToDateCheck_WithNoChanges_DoesNotReplayWarningsForProjectsWithSuppressedWarnings() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); var dgSpec = new DependencyGraphSpec(); dgSpec.AddProject(projectA); dgSpec.AddRestore(projectA.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectB); dgSpec.AddRestore(projectB.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(projectC); dgSpec.AddRestore(projectC.RestoreMetadata.ProjectUniqueName); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var testLogger = new TestLogger(); var actual = checker.PerformUpToDateCheck(dgSpec, testLogger); var expected = GetUniqueNames(projectA, projectB, projectC); actual.Should().BeEquivalentTo(expected); // ProjectC will have a warning, but these warnings are not cached because they are from projects that have their warnings/errors suppressed. var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>() { projectC.RestoreMetadata.ProjectUniqueName }, projectA, projectB, projectC); // The test logger will not contain any messages because we are not running actual restore. testLogger.WarningMessages.Should().BeEmpty(); checker.SaveRestoreStatus(results); // Act & Assert. testLogger = new TestLogger(); actual = checker.PerformUpToDateCheck(dgSpec, testLogger); testLogger.WarningMessages.Should().BeEmpty(); actual.Should().BeEmpty(); } }
public void PerformUpToDateCheck_WhenNonBuildIntegratedProjectIsAParentOfADirtySpec_ReturnsAListWithoutNonBuildIntegratedProjects() { var projectA = GetPackageSpec("A"); var projectB = GetPackageSpec("B"); var projectC = GetPackageSpec("C"); var projectD = GetPackageSpec("D"); var projectE = GetPackageSpec("E"); var projectF = GetUnknownPackageSpec("F"); // A => B & D & E projectA = projectA.WithTestProjectReference(projectB).WithTestProjectReference(projectD).WithTestProjectReference(projectE); // B => C projectB = projectB.WithTestProjectReference(projectC); // E => F projectE = projectE.WithTestProjectReference(projectF); DependencyGraphSpec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE, projectF); var checker = new SolutionUpToDateChecker(); var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC, projectD, projectE); actual.Should().BeEquivalentTo(expected); // Now we run var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD, projectE); checker.SaveRestoreStatus(results); // Prepare the new DG Spec: // Make projectE dirty by setting a random value that's usually not there :) projectF = projectF.Clone(); projectF.RestoreMetadata.PackagesPath = @"C:\"; dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE, projectF); // Act & Assert. expected = GetUniqueNames(projectA, projectE); actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); actual.Should().BeEquivalentTo(expected); }
public void PerformUpToDateCheck_WithFailedPastRestore_ReturnsADirtyProject() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetPackageSpec("C", testDirectory.Path); // A => B projectA = projectA.WithTestProjectReference(projectB); // B => C projectB = projectB.WithTestProjectReference(projectC); DependencyGraphSpec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); new List <string>() { projectA.RestoreMetadata.ProjectUniqueName, projectB.RestoreMetadata.ProjectUniqueName, projectC.RestoreMetadata.ProjectUniqueName }.Should().BeEquivalentTo(actual); // Set-up, ensure the last status for projectC is a failure. var results = RunRestore(failedProjects: new HashSet <string>() { projectC.RestoreMetadata.ProjectUniqueName }, projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC); checker.SaveRestoreStatus(results); // Act & Assert actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = new List <string>() { projectC.RestoreMetadata.ProjectUniqueName }; actual.Should().BeEquivalentTo(expected); } }
public void PerformUpToDateCheck_WithProjectJsonProjects_ReturnsOnlyDirtyProjects() { using (var testDirectory = TestDirectory.Create()) { var projectA = GetPackageSpec("A", testDirectory.Path); var projectB = GetPackageSpec("B", testDirectory.Path); var projectC = GetProjectJsonPackageSpec("C", testDirectory.Path); var projectD = GetProjectJsonPackageSpec("D", testDirectory.Path); // A => B & C projectA = projectA.WithTestProjectReference(projectB).WithTestProjectReference(projectC); DependencyGraphSpec dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD); var checker = new SolutionUpToDateChecker(); // Preconditions, run 1st check var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); var expected = GetUniqueNames(projectA, projectB, projectC, projectD); actual.Should().BeEquivalentTo(expected); var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD); checker.SaveRestoreStatus(results); // Set-up, make C dirty. projectC = projectC.Clone(); projectC.RestoreMetadata.ConfigFilePaths = new List <string>() { "newFeed" }; dgSpec = ProjectJsonTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD); // Act & Assert actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance); expected = GetUniqueNames(projectA, projectC); actual.Should().BeEquivalentTo(expected); } }