Skip to content

Commit

Permalink
Keep stdout for test execution
Browse files Browse the repository at this point in the history
Work around microsoft/vstest#1503 by using the
MSBuild escape hatch variable MSBUILDENSURESTDOUTFORTASKPROCESSES and
ensuring that tests don't run in a disconnected MSBuild process by
passing /nr:false.
  • Loading branch information
rainersigwald committed Mar 25, 2018
1 parent 5e67650 commit 29ac66f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/dotnet/commands/dotnet-test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static TestCommand FromArgs(string[] args, string msbuildPath = null)
{
"/t:VSTest",
"/v:quiet",
"/nodereuse:false", // workaround for https://github.com/Microsoft/vstest/issues/1503
"/nologo"
};

Expand Down Expand Up @@ -95,7 +96,23 @@ public static int Run(string[] args)
return e.ExitCode;
}

return cmd.Execute();
// Workaround for https://github.com/Microsoft/vstest/issues/1503
const string NodeWindowEnvironmentName = "MSBUILDENSURESTDOUTFORTASKPROCESSES";
string previousNodeWindowSetting = Environment.GetEnvironmentVariable(NodeWindowEnvironmentName);

int result = -1;

try
{
Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, "1");
result = cmd.Execute();
}
finally
{
Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, previousNodeWindowSetting);
}

return result;
}

private static string GetSemiColonEscapedString(string arg)
Expand Down

0 comments on commit 29ac66f

Please sign in to comment.