-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet test is incompatible with MSBuild node reuse #1503
Comments
@rainersigwald I think you are talking about this change. We have did this to show the output in color. |
Work around microsoft/vstest#1503 by using the MSBuild escape hatch variable MSBUILDNODEWINDOW and ensuring that tests don't run in a disconnected MSBuild process by passing /nr:false.
Work around microsoft/vstest#1503 by using the MSBuild escape hatch variable MSBUILDNODEWINDOW and ensuring that tests don't run in a disconnected MSBuild process by passing /nr:false.
@smadala That's part of it. Let's discuss options early in the week. The current approach will be really broken going forward. |
Work around microsoft/vstest#1503 by using the MSBuild escape hatch variable MSBUILDNODEWINDOW and ensuring that tests don't run in a disconnected MSBuild process by passing /nr:false.
The VSTest runner emits log messages to its stdout. So far, in .NET Core, that has resulted in them getting piped all the way up through the worker MSBuild that launched the task, the entry-point MSBuild coordinating the build, and the `dotnet test` invocation that started it all. The introduction of node reuse for .NET Core makes this untenable: worker nodes should not share stdout with the process that happened to launch them, because they will be long-lived and may do entirely unrelated builds. But for now, this breaks the `dotnet test` scenario. This commit creates an escape hatch environment variable `MSBUILDENSURESTDOUTFORTASKPROCESSES` that can be used in combination with `/nodereuse:false` to create a cone of MSBuild processes that all share std handles. Enables workaround for microsoft/vstest#1503.
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.
The VSTest runner emits log messages to its stdout. So far, in .NET Core, that has resulted in them getting piped all the way up through the worker MSBuild that launched the task, the entry-point MSBuild coordinating the build, and the `dotnet test` invocation that started it all. The introduction of node reuse for .NET Core makes this untenable: worker nodes should not share stdout with the process that happened to launch them, because they will be long-lived and may do entirely unrelated builds. But for now, this breaks the `dotnet test` scenario. This commit creates an escape hatch environment variable `MSBUILDENSURESTDOUTFORTASKPROCESSES` that can be used in combination with `/nodereuse:false` to create a cone of MSBuild processes that all share std handles. Enables workaround for microsoft/vstest#1503.
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.
@rainersigwald Is there any change required from VSTestTask? |
Below are possible solutions recommended by @rainersigwald
@rainersigwald Is there a issue tracking "colorization-of-logging"? Or should we go by different approach? |
Any progress on this? I'm struggling with this right now because VSTest output does not appear on the console or in MSBuild logging. I can't figure out why tests are failing in my build. |
Attempt to workaround microsoft/vstest#1503 which causes test failure output to be swallowed
@natemcmaster Can you please share sample repo for issue you are facing? I have tried PS C:\Users\samadala\src\tmp\msbuild-node-resue> dotnet msbuild /t:VSTest
Microsoft (R) Build Engine version 15.8.86-preview+g4ef6bb1fb2 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Build started, please wait...
You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
msbuild-node-resue -> C:\Users\samadala\src\tmp\msbuild-node-resue\bin\Debug\netcoreapp2.1\msbuild-node-resue.dll
Build completed.
Test run for C:\Users\samadala\src\tmp\msbuild-node-resue\bin\Debug\netcoreapp2.1\msbuild-node-resue.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 15.8.0-preview-20180605-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
[xUnit.net 00:00:00.7505909] msbuild_node_resue.UnitTest1.Test2 [FAIL]
Failed msbuild_node_resue.UnitTest1.Test2
Error Message:
Assert.True() Failure
Expected: True
Actual: False
Stack Trace:
at msbuild_node_resue.UnitTest1.Test2() in C:\Users\samadala\src\tmp\msbuild-node-resue\UnitTest1.cs:line 17
Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 1.5924 Seconds |
The following reproduces it for me:
Add the following to Project2\UnitTest1.cs:
Then:
I 'think' due to the parallel nature of MSBuild, it can vary which project you have to add the failing test to, but this gives me the following output:
Note, build failed, but no output of Project2 tests. |
@FlukeFan Thanks for repro steps. Let me try them. |
@FlukeFan FYI my msbuild verions |
You can also see the workaround here: My understanding is that a lot of the build performance improvement comes from paralellization of the build, but that certain (console, I think) output is lost when doing this. The workaround turns off the paralellism for |
@FlukeFan I'm able to repro the issue when invoking Unfortunately @rainersigwald @natemcmaster I observer that using |
Yes, it is. As a workaround you can set the environment variable The |
When tests run in CI, we are not displaying the test output to the console. So if a test fails, and for some reason the .trx file isn't parsed correctly, it is impossible to see what test failed and why. The test output isn't being displayed because of microsoft/vstest#1503. To work around the vstest bug, split CI builds into 2 separate MSBuild invocations: one to do the build (which is multi-proc) and another to run the tests (which doesn't need MSBuild node reuse).
I just hit this today and I'm wondering if there is a proper fix for this yet? |
There is a workaround in PR #2702 (use |
I am already using |
If it is ever merged, indeed. |
What's holding it up do you think? |
@smadala are you still actively working on this issue? |
This was solved in net9 together with terminal logger. |
I tried updating to
So it's not telling me where it failed. What am I missing? |
Moved to new issue: #5156 |
Description
In the .NET SDK 2.1.300, MSBuild on .NET Core will introduce support for node reuse. This feature enable faster cycle times by keeping MSBuild worker processes alive after the first build ends, allowing them to be reused "hot" by the second and subsequent builds.
Unfortunately, this is incompatible with the output strategy used by VSTestTask, which depends on child processes of MSBuild being attached to the stdout stream of the entry-point
dotnet test
process. That can't be the case whenvstest.console
may be run from an MSBuild that has no stdout stream.On a CLI with the new MSBuild, output from VSTest does not appear on the console.
Steps to reproduce
This is the root cause of the test failures in https://ci.dot.net/job/dotnet_cli/job/release_2.1.2xx/job/release_windows_nt_x64_prtest/41/
On a CLI with the new MSBuild, run
dotnet test
.Expected behavior
Test output is displayed from
dotnet test
regardless of MSBuild internals. From preview1:Actual behavior
Test output from
dotnet test
is lost; the build fails without error.AB#1494525
The text was updated successfully, but these errors were encountered: