Skip to content

Commit f8f062d

Browse files
committed
Fix tests
1 parent 3559b4b commit f8f062d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Build.UnitTests/BackEnd/BuildManager_Tests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,14 +760,16 @@ public void OutOfProcNodeForwardCertainpropertiesAlsoGetResultsFromCache()
760760
_env.SetEnvironmentVariable("MsBuildForwardPropertiesFromChild", "InitialProperty3;IAMNOTREAL");
761761
_env.SetEnvironmentVariable("MSBUILDNOINPROCNODE", "1");
762762

763+
_env.SetEnvironmentVariable("MSBUILDLOGPROPERTIESANDITEMSAFTEREVALUATION", "0");
764+
763765
var project = CreateProject(contents, null, _projectCollection, false);
764766
var data = new BuildRequestData(project.FullPath, new Dictionary<string, string>(),
765767
MSBuildDefaultToolsVersion, Array.Empty<string>(), null);
766768

767769
BuildResult result = _buildManager.Build(_parameters, data);
768770
Assert.Equal(BuildResultCode.Success, result.OverallResult);
769771
_logger.AssertLogContains("[success]");
770-
Assert.Equal(3, _logger.EvaluationFinishedEvents.Count);
772+
Assert.Equal(3, _logger.ProjectStartedEvents.Count);
771773

772774
ProjectStartedEventArgs projectStartedEvent = _logger.ProjectStartedEvents[1];
773775

@@ -785,7 +787,8 @@ public void OutOfProcNodeForwardCertainpropertiesAlsoGetResultsFromCache()
785787
Assert.Equal("InitialProperty3", propertyValue);
786788

787789
projectStartedEvent = _logger.ProjectStartedEvents[2];
788-
Assert.Null(projectStartedEvent.Properties);
790+
properties = ExtractProjectStartedPropertyList(projectStartedEvent.Properties);
791+
(properties == null || properties.Count == 0).ShouldBeTrue();
789792
}
790793

791794
/// <summary>

src/Shared/UnitTests/TestAssemblyInfo.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public MSBuildTestAssemblyFixture()
4141
var runningTestsField = testInfoType.GetField("s_runningTests", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
4242
runningTestsField.SetValue(null, true);
4343

44+
// Set the field in BuildEnvironmentState - as it might have been already preintialized by the data preparation of data driven tests
45+
testInfoType = frameworkAssembly.GetType("Microsoft.Build.Framework.BuildEnvironmentState");
46+
runningTestsField = testInfoType.GetField("s_runningTests", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
47+
runningTestsField.SetValue(null, true);
48+
49+
4450
// Note: build error files will be initialized in test environments for particular tests, also we don't have output to report error files into anyway...
4551
_testEnvironment = TestEnvironment.Create(output: null, ignoreBuildErrorFiles: true);
4652

0 commit comments

Comments
 (0)