-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Draft] Failing test #52980
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
Closed
Closed
[Draft] Failing test #52980
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9be401e
Add test for hanging child process for MTP
Youssef1313 bcceb0c
Create global.json
Youssef1313 60d6fd9
Update Program.cs
Youssef1313 9a52fe0
Attempt to fix hang
Youssef1313 3ecab54
Handle the 5 sec timeout
Youssef1313 53176ce
Ignore test
Youssef1313 8a0ae25
Fix build
Youssef1313 fe0bba1
Fix build
Youssef1313 7bee0bc
Switch to ConcurrentQueue
Youssef1313 51c5e9a
Unskip test, adjust test infra to allow not capturing stdout/stderr
Youssef1313 8c0a091
Revert fix - to confirm test is hanging
Youssef1313 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/TestAssets/TestProjects/MTPChildProcessHangTest/MTPChildProcessHangTest.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" /> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>$(CurrentTargetFramework)</TargetFramework> | ||
| <OutputType>Exe</OutputType> | ||
|
|
||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
|
|
||
| <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Testing.Platform" Version="$(MicrosoftTestingPlatformVersion)" /> | ||
| </ItemGroup> | ||
| </Project> |
47 changes: 47 additions & 0 deletions
47
test/TestAssets/TestProjects/MTPChildProcessHangTest/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| using System.Diagnostics; | ||
| using Microsoft.Testing.Platform.Builder; | ||
| using Microsoft.Testing.Platform.Capabilities.TestFramework; | ||
| using Microsoft.Testing.Platform.Extensions.TestFramework; | ||
|
|
||
| if (args.Length == 1 && args[0] == "hang") | ||
| { | ||
| var @event = new ManualResetEvent(false); | ||
| @event.WaitOne(); | ||
| return 0; | ||
| } | ||
|
|
||
| var builder = await TestApplication.CreateBuilderAsync(args); | ||
| builder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, _) => new MyTestFramework()); | ||
| using var testApp = await builder.BuildAsync(); | ||
| return await testApp.RunAsync(); | ||
|
|
||
| internal class MyTestFramework : ITestFramework | ||
| { | ||
| public string Uid => nameof(MyTestFramework); | ||
| public string Version => "1.0.0"; | ||
| public string DisplayName => nameof(MyTestFramework); | ||
| public string Description => DisplayName; | ||
| public Task<CloseTestSessionResult> CloseTestSessionAsync(CloseTestSessionContext context) | ||
| { | ||
| return Task.FromResult(new CloseTestSessionResult() { IsSuccess = true }); | ||
| } | ||
| public Task<CreateTestSessionResult> CreateTestSessionAsync(CreateTestSessionContext context) | ||
| => Task.FromResult(new CreateTestSessionResult() { IsSuccess = true }); | ||
| public Task ExecuteRequestAsync(ExecuteRequestContext context) | ||
| { | ||
| var fileName = Process.GetCurrentProcess().MainModule.FileName; | ||
| var p = Process.Start(new ProcessStartInfo(fileName, "hang") | ||
| { | ||
| RedirectStandardOutput = true, | ||
| RedirectStandardError = true, | ||
| }); | ||
| p.BeginOutputReadLine(); | ||
| p.BeginErrorReadLine(); | ||
| p.ErrorDataReceived += (sender, e) => { }; | ||
| p.OutputDataReceived += (sender, e) => { }; | ||
Youssef1313 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| context.Complete(); | ||
| return Task.CompletedTask; | ||
| } | ||
| public Task<bool> IsEnabledAsync() | ||
| => Task.FromResult(true); | ||
| } | ||
5 changes: 5 additions & 0 deletions
5
test/TestAssets/TestProjects/MTPChildProcessHangTest/global.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "test": { | ||
| "runner": "Microsoft.Testing.Platform" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.