Skip to content

Use Process.RunAndCaptureText in src/tests child-process helpers - #129779

Merged
AaronRobinsonMSFT merged 15 commits into
dotnet:mainfrom
AaronRobinsonMSFT:update_child_proc_in_tests
Jun 25, 2026
Merged

AaronRobinsonMSFT merged 15 commits into
dotnet:mainfrom
AaronRobinsonMSFT:update_child_proc_in_tests

Conversation

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

Adopts the new .NET 11 Process.RunAndCaptureText API across src/tests C# tests/helpers that followed the "launch a child process, wait for exit, read exit code + full stdout/stderr" pattern (no stdin, no live process control).

Converted:

  • Loader/PlatformNativeR2R/PlatformNativeR2R.cs
  • nativeaot/AggregateExecutableLibrary/ValidatorExe/ValidatorExe.cs
  • GC/Stress/Framework/RFLogging.cs (WriteToReport)
  • baseservices/exceptions/unhandled/unhandledTester.cs
  • baseservices/exceptions/stackoverflow/stackoverflowtester.cs
  • Loader/binding/tracing/BinderTracingTest.cs
  • profiler/common/ProfilerTestRunner.cs
  • nativeaot/SmokeTests/DwarfDump/Program.cs
  • tracing/userevents/common/UserEventsRequirements.cs
  • GC/Stress/Framework/ReliabilityFramework.cs (AddFailure)
  • GC/LargeMemory/memcheck.cs (RunCommand)
  • Common/CoreCLRTestLibrary/CoreclrTestWrapperLib.cs (pgrep + wmic)
  • Common/XUnitLogChecker/XUnitLogChecker.cs (RunProcess)

Call sites that write to stdin, coordinate with a live process (PID/signals/EventPipe), or rely on sudo/root process-tree kills were intentionally left unchanged.

Note

This PR description was generated with the assistance of GitHub Copilot.

AaronRobinsonMSFT and others added 13 commits June 23, 2026 13:55
@github-actions github-actions Bot added the area-Infrastructure-coreclr Only use for closed issues label Jun 23, 2026
@AaronRobinsonMSFT AaronRobinsonMSFT changed the title Use Process.RunAndCaptureText in src/tests child-process helpers Use Process.RunAndCaptureText in src/tests child-process helpers Jun 23, 2026
@AaronRobinsonMSFT AaronRobinsonMSFT added test-enhancement Improvements of test source code area-Infrastructure and removed area-Infrastructure-coreclr Only use for closed issues labels Jun 23, 2026
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 11.0.0 milestone Jun 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors multiple src/tests helpers and test utilities to use System.Diagnostics.Process.RunAndCaptureText / ProcessTextOutput for the common “run child process, capture full stdout/stderr, check exit code” pattern.

Changes:

  • Replaces ad-hoc Process.Start + async stream reads / event handlers with Process.RunAndCaptureText(...) across several test areas.
  • Updates call sites to consume ProcessTextOutput.StandardOutput / .StandardError and result.ExitStatus.ExitCode (and timeout cancellation where applicable).
  • Simplifies a few helpers by removing manual WaitForExit / ReadToEndAsync patterns.
Show a summary per file
File Description
src/tests/tracing/userevents/common/UserEventsRequirements.cs Switches tracefs/user_events/ldd checks to RunAndCaptureText and prints captured output lines.
src/tests/profiler/common/ProfilerTestRunner.cs Refactors profilee execution to RunAndCaptureText and verifies captured stdout via TextReader.
src/tests/nativeaot/SmokeTests/DwarfDump/Program.cs Uses RunAndCaptureText for the llvm-dwarfdump --verify invocation and parses captured output.
src/tests/nativeaot/AggregateExecutableLibrary/ValidatorExe/ValidatorExe.cs Simplifies ValidatorExe process execution using captured stdout/stderr and exit code.
src/tests/Loader/PlatformNativeR2R/PlatformNativeR2R.cs Uses captured stdout/stderr for R2RDump execution and failure reporting.
src/tests/Loader/binding/tracing/BinderTracingTest.cs Runs subprocess via RunAndCaptureText and writes captured stdout/stderr to the console.
src/tests/GC/Stress/Framework/RFLogging.cs Updates status-reporting script invocation to RunAndCaptureText.
src/tests/GC/Stress/Framework/ReliabilityFramework.cs Updates harness status reporting invocation to RunAndCaptureText.
src/tests/GC/LargeMemory/memcheck.cs Uses RunAndCaptureText for a simple command execution helper.
src/tests/Common/XUnitLogChecker/XUnitLogChecker.cs Replaces manual timeout/kill/read logic with RunAndCaptureText(..., timeout) and checks ExitStatus.Canceled.
src/tests/Common/CoreCLRTestLibrary/CoreclrTestWrapperLib.cs Uses RunAndCaptureText for pgrep and wmic helpers, capturing output text directly.
src/tests/baseservices/exceptions/unhandled/unhandledTester.cs Refactors subprocess execution to RunAndCaptureText and parses captured stderr lines.
src/tests/baseservices/exceptions/stackoverflow/stackoverflowtester.cs Refactors subprocess execution to RunAndCaptureText and parses captured stderr lines.

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 6

Process.RunAndCaptureText throws InvalidOperationException unless both
RedirectStandardOutput and RedirectStandardError are set. Several converted
call sites only redirected one stream. Also fix RFLogging status message
to include the failing exit code via a {0} placeholder.

Co-authored-by: Copilot <[email protected]>
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AaronRobinsonMSFT big thanks for dogfooding the new APIs! I've left some comments, PTAL

- BinderTracingTest: use Process.Run to inherit parent std handles
- ValidatorExe: trim stderr only when reporting failure
- ProfilerTestRunner: drop redundant parent env var copy
- XUnitLogChecker: catch TimeoutException instead of checking Canceled
- stackoverflowtester, UserEventsRequirements: use ReadAllLines

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 3

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, again thanks for using the new APIs @AaronRobinsonMSFT !

@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit 9a852a8 into dotnet:main Jun 25, 2026
87 checks passed
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the update_child_proc_in_tests branch June 25, 2026 15:01
@github-project-automation github-project-automation Bot moved this to Done in AppModel Jun 25, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview7 Jun 26, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
…129779)

Adopts the new .NET 11 `Process.RunAndCaptureText` API across
`src/tests` C# tests/helpers that followed the "launch a child process,
wait for exit, read exit code + full stdout/stderr" pattern.

Converted:
- `Loader/PlatformNativeR2R/PlatformNativeR2R.cs`
- `nativeaot/AggregateExecutableLibrary/ValidatorExe/ValidatorExe.cs`
- `GC/Stress/Framework/RFLogging.cs` (`WriteToReport`)
- `baseservices/exceptions/unhandled/unhandledTester.cs`
- `baseservices/exceptions/stackoverflow/stackoverflowtester.cs`
- `Loader/binding/tracing/BinderTracingTest.cs`
- `profiler/common/ProfilerTestRunner.cs`
- `nativeaot/SmokeTests/DwarfDump/Program.cs`
- `tracing/userevents/common/UserEventsRequirements.cs`
- `GC/Stress/Framework/ReliabilityFramework.cs` (`AddFailure`)
- `GC/LargeMemory/memcheck.cs` (`RunCommand`)
- `Common/CoreCLRTestLibrary/CoreclrTestWrapperLib.cs` (pgrep + wmic)
- `Common/XUnitLogChecker/XUnitLogChecker.cs` (`RunProcess`)
---------

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Infrastructure test-enhancement Improvements of test source code

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants