Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Build.UnitTests/TerminalLoggerConfiguration_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public TerminalLoggerConfiguration_Tests(ITestOutputHelper output)
{
_env = TestEnvironment.Create(output);

// Ignore environment variables that may have been set by the environment where the tests are running.
_env.SetEnvironmentVariable("MSBUILDLIVELOGGER", null);
_env.SetEnvironmentVariable("MSBUILDTERMINALLOGGER", null);

TransientTestFolder logFolder = _env.CreateFolder(createFolder: true);
TransientTestFile projectFile = _env.CreateFile(logFolder, "myProj.proj", $"""
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Hello">
Expand Down
6 changes: 3 additions & 3 deletions src/MSBuild.UnitTests/MSBuildServer_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class MSBuildServer_Tests : IDisposable
<ProcessIdTask>
<Output PropertyName=""PID"" TaskParameter=""Pid"" />
</ProcessIdTask>
<Message Text=""Server ID is $(PID)"" Importance=""High"" />
<Message Text=""[Work around Github issue #9667 with --interactive]Server ID is $(PID)"" Importance=""High"" />
</Target>
</Project>";
private static string sleepingTaskContentsFormat = @$"
Expand Down Expand Up @@ -313,8 +313,8 @@ public void PropertyMSBuildStartupDirectoryOnServer()
<ProcessIdTask>
<Output PropertyName=""PID"" TaskParameter=""Pid"" />
</ProcessIdTask>
<Message Text=""Server ID is $(PID)"" Importance=""High"" />
<Message Text="":MSBuildStartupDirectory:$(MSBuildStartupDirectory):"" Importance=""high"" />
<Message Text=""[Work around Github issue #9667 with --interactive]Server ID is $(PID)"" Importance=""High"" />
<Message Text=""[Work around Github issue #9667 with --interactive]:MSBuildStartupDirectory:$(MSBuildStartupDirectory):"" Importance=""high"" />
</Target>
</Project>";

Expand Down
10 changes: 7 additions & 3 deletions src/UnitTests.Shared/TestEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static TestEnvironment Create(ITestOutputHelper output = null, bool ignor
env.WithInvariant(new BuildFailureLogInvariant());
}

// Clear these two environment variables first in case pre-setting affects the test.
env.SetEnvironmentVariable("MSBUILDLIVELOGGER", null);
env.SetEnvironmentVariable("MSBUILDTERMINALLOGGER", null);

return env;
}

Expand Down Expand Up @@ -83,10 +87,10 @@ private void Cleanup()
{
_disposed = true;

// Reset test variants
foreach (var variant in _variants)
// Reset test variants in reverse order to get back to original state.
for (int i = _variants.Count - 1; i >= 0; i--)
{
variant.Revert();
_variants[i].Revert();
}

// Assert invariants
Expand Down