Skip to content

[Draft] Failing test#52980

Closed
Youssef1313 wants to merge 11 commits intomainfrom
dev/ygerges/child-process-mtp-test-only
Closed

[Draft] Failing test#52980
Youssef1313 wants to merge 11 commits intomainfrom
dev/ygerges/child-process-mtp-test-only

Conversation

@Youssef1313
Copy link
Member

DRAFT: Need to get to a state where a test fails on current main but passes with the fix in #52558

Copilot AI review requested due to automatic review settings February 11, 2026 11:36
@Youssef1313 Youssef1313 requested a review from a team as a code owner February 11, 2026 11:36
@Youssef1313 Youssef1313 marked this pull request as draft February 11, 2026 11:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MTPChildProcessHangTest test project that spawns a “hanging” child process under Microsoft.Testing.Platform.
  • Add a new DotnetTest_MTPChildProcessHangTestProject_ShouldNotHang test case for Debug/Release.
  • Add DisableOutputAndErrorRedirection plumbing 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.

Comment on lines +6 to +11
if (args.Length == 1 && args[0] == "hang")
{
var @event = new ManualResetEvent(false);
@event.WaitOne();
return 0;
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@Youssef1313
Copy link
Member Author

The active Test Run was aborted because the host process exited unexpectedly. Please inspect the call stack above, if available, to get more information about where the exception originated from.
The test running when the crash occurred: 
Microsoft.DotNet.Cli.Test.Tests.GivenDotnetTestBuildsAndRunsTests.DotnetTest_MTPChildProcessHangTestProject_ShouldNotHang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants