@@ -32,8 +32,8 @@ struct Echo {
32
32
var configuration : Configuration {
33
33
#if os(Windows)
34
34
return Configuration (
35
- executable: . name( " cmd .exe" ) ,
36
- arguments: Arguments ( [ " /c " , " echo " , message] )
35
+ executable: . name( " powershell .exe" ) ,
36
+ arguments: Arguments ( [ " -Command " , " Write-Host ' \( message) ' -NoNewline " ] )
37
37
)
38
38
#else
39
39
return Configuration (
@@ -81,22 +81,22 @@ struct Wc {
81
81
if options. contains ( " -l " ) {
82
82
return Configuration (
83
83
executable: . name( " powershell.exe " ) ,
84
- arguments: Arguments ( [ " -Command " , " (Get-Content -Raw | Measure-Object -Line).Lines " ] )
84
+ arguments: Arguments ( [ " -Command " , " ($input | Measure-Object -Line).Lines " ] )
85
85
)
86
86
} else if options. contains ( " -w " ) {
87
87
return Configuration (
88
88
executable: . name( " powershell.exe " ) ,
89
- arguments: Arguments ( [ " -Command " , " (Get-Content -Raw | Measure-Object -Word).Words " ] )
89
+ arguments: Arguments ( [ " -Command " , " ($input | Measure-Object -Word).Words " ] )
90
90
)
91
91
} else if options. contains ( " -c " ) {
92
92
return Configuration (
93
93
executable: . name( " powershell.exe " ) ,
94
- arguments: Arguments ( [ " -Command " , " (Get-Content -Raw | Measure-Object -Character).Characters " ] )
94
+ arguments: Arguments ( [ " -Command " , " ($input | Measure-Object -Character).Characters " ] )
95
95
)
96
96
} else {
97
97
return Configuration (
98
98
executable: . name( " powershell.exe " ) ,
99
- arguments: Arguments ( [ " -Command " , " Get-Content -Raw | Measure-Object -Line -Word -Character" ] )
99
+ arguments: Arguments ( [ " -Command " , " $input | Measure-Object -Line -Word -Character" ] )
100
100
)
101
101
}
102
102
#else
@@ -732,14 +732,15 @@ struct PipeConfigurationTests {
732
732
// MARK: - Shared Error Handling Tests
733
733
734
734
@Test func testSharedErrorHandlingInPipeline( ) async throws {
735
+ // FIXME - There is a race condition here that truncates the stderr on both Linux and macOS - The sleep helps to mitigate
735
736
let pipeline =
736
737
pipe (
737
- configuration: Shell ( " echo 'first stdout'; echo 'first stderr' >&2 " ) . configuration
738
+ configuration: Shell ( " echo 'first stdout'; echo 'first stderr' >&2; sleep 1 " ) . configuration
738
739
)
739
- | Shell( " echo 'second stdout'; echo 'second stderr' >&2 " ) . configuration
740
+ | Shell( " echo 'second stdout'; echo 'second stderr' >&2; sleep 1 " ) . configuration
740
741
|> (
741
742
output: . string( limit: . max) ,
742
- error: . string( limit: . max )
743
+ error: . string( limit: 1024 ) ,
743
744
)
744
745
745
746
let result = try await pipeline. run ( )
0 commit comments