[tests] Add DotNetRunCtrlC integration test#11293
Draft
jonathanpeppers wants to merge 1 commit intomainfrom
Draft
[tests] Add DotNetRunCtrlC integration test#11293jonathanpeppers wants to merge 1 commit intomainfrom
jonathanpeppers wants to merge 1 commit intomainfrom
Conversation
c4c574d to
f65d066
Compare
Add a device integration test that verifies Ctrl+C (SIGINT) sent to
`dotnet run` properly stops the Android app on the device/emulator.
The test:
1. Builds and launches an Android app via `dotnet run` with WaitForExit
2. Waits for app logcat output confirming launch
3. Verifies the app PID exists on the device
4. Sends SIGINT via Process.SendCtrlC() extension method
5. Asserts the process exits gracefully
6. Verifies Microsoft.Android.Run's Ctrl+C handler ran ("Stopping application...")
7. Confirms the app is no longer running on the device
Also adds a `SendCtrlC()` extension method on `Process` in
`ProcessExtensions.cs`. On Unix/macOS, it uses `pgrep` to find all
descendant processes and sends SIGINT to the entire process tree,
simulating what a real terminal Ctrl+C does (SIGINT to the whole
foreground process group). Without this, child processes like
`Microsoft.Android.Run` (launched by `dotnet run` via MSBuild) would
not receive the signal.
Fixes a bug in `Microsoft.Android.Run` where `OperationCanceledException`
from `GetAppPidAsync()` would escape through the top-level catch block
when Ctrl+C was pressed, printing "Error: The operation was canceled."
instead of exiting cleanly.
Fixes: #11264
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f65d066 to
996bb8f
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a device integration test that verifies Ctrl+C (SIGINT) sent to
dotnet runproperly stops the Android app on the device/emulator.Test flow:
dotnet runwithWaitForExit=trueadb shell pidofprocess.SendCtrlC()extension methodMicrosoft.Android.Run's Ctrl+C handler ran ("Stopping application...")Also adds a
SendCtrlC()extension method onProcessinProcessExtensions.cs, using libckill(pid, SIGINT)P/Invoke (Unix/macOS only; throwsPlatformNotSupportedExceptionon Windows).Fixes #11264