Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new test asset and an xUnit test intended to reproduce/guard against the dotnet test hang scenario described in #52558 (test app exits while a child process remains alive), plus a small test-framework tweak to optionally avoid stdout/stderr capture.
Changes:
- Add
MTPChildProcessHangTesttest project that spawns a “hanging” child process under Microsoft.Testing.Platform. - Add a new
DotnetTest_MTPChildProcessHangTestProject_ShouldNotHangtest case for Debug/Release. - Add
DisableOutputAndErrorRedirectionplumbing to the test command harness to optionally skip stdout/stderr capture.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs | Adds a new test case that runs dotnet test against the new MTP asset. |
| test/TestAssets/TestProjects/MTPChildProcessHangTest/global.json | Forces the test runner to Microsoft.Testing.Platform for the asset. |
| test/TestAssets/TestProjects/MTPChildProcessHangTest/Program.cs | Implements a minimal MTP test app that spawns a child process intended to remain alive. |
| test/TestAssets/TestProjects/MTPChildProcessHangTest/MTPChildProcessHangTest.csproj | Defines the new test asset project and references Microsoft.Testing.Platform. |
| test/Microsoft.NET.TestFramework/Commands/TestCommand.cs | Adds an option to skip stdout/stderr capture and forwarding in the test harness. |
| test/Microsoft.NET.TestFramework/Commands/SdkCommandSpec.cs | Carries the new disable-redirection flag through the command spec. |
| src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs | Encoding/first-line change only. |
| if (args.Length == 1 && args[0] == "hang") | ||
| { | ||
| var @event = new ManualResetEvent(false); | ||
| @event.WaitOne(); | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
The "hang" mode blocks indefinitely on a ManualResetEvent and the parent never cleans it up. If the dotnet test side stops hanging (or is killed by a timeout), this can leave an orphaned process running forever in CI. Make the child self-terminate after a bounded timeout (or implement explicit cleanup/kill logic) to avoid leaking processes.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs
Show resolved
Hide resolved
|
DRAFT: Need to get to a state where a test fails on current main but passes with the fix in #52558