From bbcab237d85743c569eeaab0bd6a5298970320e8 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 17 Jul 2024 14:54:11 +0200 Subject: [PATCH] Don't rely on error code returned on Windows Nano (#104973) Fixes #104770 --- .../tests/ProcessStartInfoTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs index 3992857ce574b..728e52f520208 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs @@ -1267,13 +1267,13 @@ public void StartInfo_BadExe(bool useShellExecute) FileName = tempFile }; - int expected = ERROR_BAD_EXE_FORMAT; - - // Windows Nano bug see https://github.com/dotnet/runtime/issues/17919 - if (PlatformDetection.IsWindowsNanoServer) - expected = ERROR_SUCCESS; - - Assert.Equal(expected, Assert.Throws(() => Process.Start(info)).NativeErrorCode); + int errorCode = Assert.Throws(() => Process.Start(info)).NativeErrorCode; + + if (!PlatformDetection.IsWindowsNanoServer) + { + // We can not rely on the error code returned on Windows Nano https://github.com/dotnet/runtime/issues/17919 + Assert.Equal(ERROR_BAD_EXE_FORMAT, errorCode); + } } [Fact]