Skip to content

Commit

Permalink
ProcessWatchdogTest: only check exit code 259 on Windows
Browse files Browse the repository at this point in the history
This code is out of range of valid exit codes on Unix anyway.
  • Loading branch information
ForNeVeR committed Dec 2, 2023
1 parent d2107f0 commit b447060
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rd-net/Test.Lifetimes/Diagnostics/ProcessWatchdogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ProcessWatchdogTest : LifetimesTestBase
[Test]
public Task TestWithSleepingProcess() => DoTest(StartSleepingProcess, true);

[Test]
[Test, Platform("Win")]
public Task TestWithProcessReturning259() => DoTest(() => GetTerminatedProcess(259), false);

private static Task DoTest(Func<Process> processCreator, bool assertAlive) => Lifetime.UsingAsync(async lt =>
Expand Down Expand Up @@ -82,12 +82,12 @@ private Process StartSleepingProcess()

private Process GetTerminatedProcess(int exitCode)
{
var process = RuntimeInfo.IsRunningUnderWindows
? Process.Start(new ProcessStartInfo("cmd.exe", $"/c exit {exitCode.ToString(CultureInfo.InvariantCulture)}")
Assertion.Assert(RuntimeInfo.IsRunningUnderWindows);
var process = Process.Start(
new ProcessStartInfo("cmd.exe", $"/c exit {exitCode.ToString(CultureInfo.InvariantCulture)}")
{
WindowStyle = ProcessWindowStyle.Hidden
})
: Process.Start("/usr/bin/sh", $"-c \"exit {exitCode.ToString(CultureInfo.InvariantCulture)}\"");
});
process!.WaitForExit();
Assert.AreEqual(exitCode, process.ExitCode);
return process;
Expand Down

0 comments on commit b447060

Please sign in to comment.