@@ -27,7 +27,7 @@ import TestResources
27
27
28
28
@Suite ( . serialized)
29
29
struct SubprocessWindowsTests {
30
- private let cmdExe : Subprocess . Executable = . path ( " C: \\ Windows \\ System32 \\ cmd.exe " )
30
+ private let cmdExe : Subprocess . Executable = . name ( " cmd.exe " )
31
31
}
32
32
33
33
// MARK: - Executable Tests
@@ -87,7 +87,7 @@ extension SubprocessWindowsTests {
87
87
Issue . record ( " Expected to throw POSIXError " )
88
88
} catch {
89
89
guard let subprocessError = error as? SubprocessError ,
90
- let underlying = subprocessError. underlyingError
90
+ let underlying = subprocessError. underlyingError
91
91
else {
92
92
Issue . record ( " Expected CocoaError, got \( error) " )
93
93
return
@@ -128,7 +128,6 @@ extension SubprocessWindowsTests {
128
128
environment: . inherit,
129
129
output: . string
130
130
)
131
- #expect( result. terminationStatus. isSuccess)
132
131
// As a sanity check, make sure there's
133
132
// `C:\Windows\system32` in PATH
134
133
// since we inherited the environment variables
@@ -249,7 +248,6 @@ extension SubprocessWindowsTests {
249
248
output: . data( limit: 2048 * 1024 )
250
249
)
251
250
252
- #expect( catResult. terminationStatus. isSuccess)
253
251
// Make sure we read all bytes
254
252
#expect(
255
253
catResult. standardOutput == expected
@@ -304,7 +302,6 @@ extension SubprocessWindowsTests {
304
302
input: . sequence( stream) ,
305
303
output: . data( limit: 2048 * 1024 )
306
304
)
307
- #expect( catResult. terminationStatus. isSuccess)
308
305
#expect(
309
306
catResult. standardOutput == expected
310
307
)
@@ -510,7 +507,7 @@ extension SubprocessWindowsTests {
510
507
@Test func testPlatformOptionsCreateNewConsole( ) async throws {
511
508
let parentConsole = GetConsoleWindow ( )
512
509
let sameConsoleResult = try await Subprocess . run (
513
- . path ( " C: \\ Windows \\ System32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe " ) ,
510
+ . name ( " powershell.exe " ) ,
514
511
arguments: [
515
512
" -File " , windowsTester. string,
516
513
" -mode " , " get-console-window " ,
@@ -529,7 +526,7 @@ extension SubprocessWindowsTests {
529
526
var platformOptions : Subprocess . PlatformOptions = . init( )
530
527
platformOptions. consoleBehavior = . createNew
531
528
let differentConsoleResult = try await Subprocess . run (
532
- . path ( " C: \\ Windows \\ System32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe " ) ,
529
+ . name ( " powershell.exe " ) ,
533
530
arguments: [
534
531
" -File " , windowsTester. string,
535
532
" -mode " , " get-console-window " ,
@@ -700,12 +697,13 @@ extension SubprocessWindowsTests {
700
697
0
701
698
)
702
699
let pid = try Subprocess . runDetached (
703
- . path ( " C: \\ Windows \\ System32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe " ) ,
700
+ . name ( " powershell.exe " ) ,
704
701
arguments: [
705
702
" -Command " , " Write-Host $PID " ,
706
703
] ,
707
704
output: writeFd
708
705
)
706
+ try writeFd. close ( )
709
707
// Wait for process to finish
710
708
guard
711
709
let processHandle = OpenProcess (
0 commit comments