Skip to content

Commit d3016f2

Browse files
committed
RemoteExecutor does not support getting application arguments, Process.WaitForExitAsync is available only on .NET 7+
1 parent 158e469 commit d3016f2

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/System.CommandLine.Tests/Invocation/CancelOnProcessTerminationTests.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public enum Signals
2929
[Fact]
3030
public async Task CancellableHandler_is_cancelled_on_process_termination()
3131
{
32-
// the feature is supported on Windows, but it's simply harder to send SIGINT to test it properly
33-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
32+
// The feature is supported on Windows, but it's simply harder to send SIGINT to test it properly.
33+
// Same for macOS, where RemoteExecutor does not support getting application arguments.
34+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
3435
{
3536
await StartKillAndVerify(new[] { "--infiniteDelay", "false" }, Signals.SIGINT, GracefulExitCode);
3637
}
@@ -39,7 +40,7 @@ public async Task CancellableHandler_is_cancelled_on_process_termination()
3940
[Fact]
4041
public async Task NonCancellableHandler_is_interrupted_on_process_termination()
4142
{
42-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
43+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
4344
{
4445
await StartKillAndVerify(new[] { "--infiniteDelay", "true" }, Signals.SIGTERM, SIGTERM_EXIT_CODE);
4546
}
@@ -95,16 +96,9 @@ private async Task StartKillAndVerify(string[] args, Signals signal, int expecte
9596
kill(process.Id, (int)signal).Should().Be(0);
9697

9798
// Verify the process terminates timely
98-
try
99-
{
100-
using CancellationTokenSource cts = new (TimeSpan.FromSeconds(10));
101-
await process.WaitForExitAsync(cts.Token);
102-
}
103-
catch (OperationCanceledException)
99+
if (!process.WaitForExit(TimeSpan.FromSeconds(10)))
104100
{
105101
process.Kill();
106-
107-
throw;
108102
}
109103

110104
// Verify the process exit code

0 commit comments

Comments
 (0)