Skip to content

Commit d292465

Browse files
committed
Work around test stability and cross-platform problems
1 parent 89252e6 commit d292465

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Tests/SubprocessTests/PipeConfigurationTests.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ struct Echo {
3232
var configuration: Configuration {
3333
#if os(Windows)
3434
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"])
3737
)
3838
#else
3939
return Configuration(
@@ -81,22 +81,22 @@ struct Wc {
8181
if options.contains("-l") {
8282
return Configuration(
8383
executable: .name("powershell.exe"),
84-
arguments: Arguments(["-Command", "(Get-Content -Raw | Measure-Object -Line).Lines"])
84+
arguments: Arguments(["-Command", "($input | Measure-Object -Line).Lines"])
8585
)
8686
} else if options.contains("-w") {
8787
return Configuration(
8888
executable: .name("powershell.exe"),
89-
arguments: Arguments(["-Command", "(Get-Content -Raw | Measure-Object -Word).Words"])
89+
arguments: Arguments(["-Command", "($input | Measure-Object -Word).Words"])
9090
)
9191
} else if options.contains("-c") {
9292
return Configuration(
9393
executable: .name("powershell.exe"),
94-
arguments: Arguments(["-Command", "(Get-Content -Raw | Measure-Object -Character).Characters"])
94+
arguments: Arguments(["-Command", "($input | Measure-Object -Character).Characters"])
9595
)
9696
} else {
9797
return Configuration(
9898
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"])
100100
)
101101
}
102102
#else
@@ -732,14 +732,15 @@ struct PipeConfigurationTests {
732732
// MARK: - Shared Error Handling Tests
733733

734734
@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
735736
let pipeline =
736737
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
738739
)
739-
| Shell("echo 'second stdout'; echo 'second stderr' >&2").configuration
740+
| Shell("echo 'second stdout'; echo 'second stderr' >&2; sleep 1").configuration
740741
|> (
741742
output: .string(limit: .max),
742-
error: .string(limit: .max)
743+
error: .string(limit: 1024),
743744
)
744745

745746
let result = try await pipeline.run()

0 commit comments

Comments
 (0)