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 24, 2018
1 parent cd646d2 commit d98928e
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 d98928e

Please sign in to comment.