Skip to content

Commit 6d247b6

Browse files
committed
Make tests more platform independent
1 parent 0a8a0e5 commit 6d247b6

File tree

1 file changed

+22
-36
lines changed

1 file changed

+22
-36
lines changed

Tests/SubprocessTests/PipeConfigurationTests.swift

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ struct PipeConfigurationTests {
390390
let result = try await pipeline.run()
391391
// Should count characters in "single line\n" (12 characters)
392392
let charCount = result.standardOutput?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
393-
#expect(charCount == "12")
393+
#expect(charCount == "12" || charCount == "11") // Variation depending on the platform
394394
#expect(result.terminationStatus.isSuccess)
395395
}
396396

@@ -413,17 +413,16 @@ struct PipeConfigurationTests {
413413
@Test func testPipeOperatorWithProcessHelper() async throws {
414414
let pipeline =
415415
pipe(
416-
executable: .name("echo"),
417-
arguments: ["apple\nbanana\ncherry\ndate"]
416+
configuration: Echo("""
417+
apple
418+
banana
419+
cherry
420+
date
421+
""").configuration
418422
)
419-
| process(
420-
executable: .name("head"),
421-
arguments: ["-3"] // Take first 3 lines
422-
)
423-
| process(
424-
executable: .name("wc"),
425-
arguments: ["-l"]
426-
) |> .string(limit: .max)
423+
| Head("-3").configuration
424+
| Wc("-l").configuration
425+
|> .string(limit: .max)
427426

428427
let result = try await pipeline.run()
429428
let lineCount = result.standardOutput?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
@@ -546,13 +545,10 @@ struct PipeConfigurationTests {
546545

547546
let pipeline =
548547
pipe(
549-
executable: .name("head"),
550-
arguments: ["-3"]
548+
configuration: Head("-3").configuration
551549
)
552-
| process(
553-
executable: .name("wc"),
554-
arguments: ["-l"]
555-
) |> (
550+
| Wc("-l").configuration
551+
|> (
556552
input: .fileDescriptor(fileDescriptor, closeAfterSpawningProcess: false),
557553
output: .string(limit: .max),
558554
error: .discarded
@@ -643,7 +639,7 @@ struct PipeConfigurationTests {
643639
}
644640
return 0
645641
}
646-
) | .name("cat")
642+
) | Cat().configuration
647643
|> (
648644
input: .string(csvData),
649645
output: .string(limit: .max),
@@ -872,16 +868,11 @@ struct PipeConfigurationTests {
872868
@Test func testProcessHelperWithErrorRedirection() async throws {
873869
let pipeline =
874870
pipe(
875-
executable: .name("echo"),
876-
arguments: ["data"]
871+
configuration: Echo("data").configuration
877872
)
878-
| process(
879-
executable: .name("cat") // Simple passthrough, no error redirection needed
880-
)
881-
| process(
882-
executable: .name("wc"),
883-
arguments: ["-c"]
884-
) |> .string(limit: .max)
873+
| Cat().configuration // Simple passthrough, no error redirection needed
874+
| Wc("-c").configuration
875+
|> .string(limit: .max)
885876

886877
let result = try await pipeline.run()
887878
// Should count characters in "data\n" (5 characters)
@@ -951,16 +942,11 @@ struct PipeConfigurationTests {
951942
@Test func testProcessHelper() async throws {
952943
let pipeline =
953944
pipe(
954-
executable: .name("echo"),
955-
arguments: ["process helper test"]
945+
configuration: Echo("process helper test").configuration
956946
)
957-
| process(
958-
executable: .name("cat")
959-
)
960-
| process(
961-
executable: .name("wc"),
962-
arguments: ["-c"]
963-
) |> .string(limit: .max)
947+
| Cat().configuration
948+
| Wc("-c").configuration
949+
|> .string(limit: .max)
964950

965951
let result = try await pipeline.run()
966952
// "process helper test\n" should be 20 characters

0 commit comments

Comments
 (0)