@@ -102,7 +102,7 @@ extension SubprocessUnixTests {
102
102
extension SubprocessUnixTests {
103
103
@Test func testArgumentsArrayLiteral( ) async throws {
104
104
let result = try await Subprocess . run (
105
- . path( " /bin/bash " ) ,
105
+ . path( " /bin/sh " ) ,
106
106
arguments: [ " -c " , " echo Hello World! " ] ,
107
107
output: . string
108
108
)
@@ -117,7 +117,7 @@ extension SubprocessUnixTests {
117
117
118
118
@Test func testArgumentsOverride( ) async throws {
119
119
let result = try await Subprocess . run (
120
- . path( " /bin/bash " ) ,
120
+ . path( " /bin/sh " ) ,
121
121
arguments: . init(
122
122
executablePathOverride: " apple " ,
123
123
remainingValues: [ " -c " , " echo $0 " ]
@@ -157,7 +157,7 @@ extension SubprocessUnixTests {
157
157
extension SubprocessUnixTests {
158
158
@Test func testEnvironmentInherit( ) async throws {
159
159
let result = try await Subprocess . run (
160
- . path( " /bin/bash " ) ,
160
+ . path( " /bin/sh " ) ,
161
161
arguments: [ " -c " , " printenv PATH " ] ,
162
162
environment: . inherit,
163
163
output: . string
@@ -173,7 +173,7 @@ extension SubprocessUnixTests {
173
173
174
174
@Test func testEnvironmentInheritOverride( ) async throws {
175
175
let result = try await Subprocess . run (
176
- . path( " /bin/bash " ) ,
176
+ . path( " /bin/sh " ) ,
177
177
arguments: [ " -c " , " printenv HOME " ] ,
178
178
environment: . inherit. updating ( [
179
179
" HOME " : " /my/new/home "
@@ -595,7 +595,7 @@ extension SubprocessUnixTests {
595
595
contentsOf: URL ( filePath: theMysteriousIsland. string)
596
596
)
597
597
let catResult = try await Subprocess . run (
598
- . path( " /bin/bash " ) ,
598
+ . path( " /bin/sh " ) ,
599
599
arguments: [ " -c " , " cat \( theMysteriousIsland. string) 1>&2 " ] ,
600
600
error: . data( limit: 2048 * 1024 )
601
601
)
@@ -668,11 +668,14 @@ extension SubprocessUnixTests {
668
668
var platformOptions = PlatformOptions ( )
669
669
platformOptions. supplementaryGroups = Array ( expectedGroups)
670
670
let idResult = try await Subprocess . run (
671
- . path ( " /usr/bin/ swift" ) ,
671
+ . name ( " swift " ) ,
672
672
arguments: [ getgroupsSwift. string] ,
673
673
platformOptions: platformOptions,
674
- output: . string
674
+ output: . string,
675
+ error: . string,
675
676
)
677
+ let error = try #require( idResult. standardError)
678
+ try #require( error == " " )
676
679
#expect( idResult. terminationStatus. isSuccess)
677
680
let ids = try #require(
678
681
idResult. standardOutput
@@ -696,7 +699,7 @@ extension SubprocessUnixTests {
696
699
// Sets the process group ID to 0, which creates a new session
697
700
platformOptions. processGroupID = 0
698
701
let psResult = try await Subprocess . run (
699
- . path( " /bin/bash " ) ,
702
+ . path( " /bin/sh " ) ,
700
703
arguments: [ " -c " , " ps -o pid,pgid -p $$ " ] ,
701
704
platformOptions: platformOptions,
702
705
output: . string
@@ -723,22 +726,22 @@ extension SubprocessUnixTests {
723
726
// Check the process ID (pid), process group ID (pgid), and
724
727
// controlling terminal's process group ID (tpgid)
725
728
let psResult = try await Subprocess . run (
726
- . path( " /bin/bash " ) ,
729
+ . path( " /bin/sh " ) ,
727
730
arguments: [ " -c " , " ps -o pid,pgid,tpgid -p $$ " ] ,
728
731
platformOptions: platformOptions,
729
732
output: . string
730
733
)
731
734
try assertNewSessionCreated ( with: psResult)
732
735
}
733
736
734
- @Test func testTeardownSequence( ) async throws {
737
+ @Test ( . requiresBash ) func testTeardownSequence( ) async throws {
735
738
let result = try await Subprocess . run (
736
- . path ( " /bin/ bash" ) ,
739
+ . name ( " bash " ) ,
737
740
arguments: [
738
741
" -c " ,
739
742
"""
740
743
set -e
741
- trap 'echo saw SIGQUIT;' SIGQUIT
744
+ trap 'echo saw SIGQUIT;' QUIT
742
745
trap 'echo saw SIGTERM;' TERM
743
746
trap 'echo saw SIGINT; exit 42;' INT
744
747
while true; do sleep 1; done
@@ -777,7 +780,7 @@ extension SubprocessUnixTests {
777
780
@Test func testRunDetached( ) async throws {
778
781
let ( readFd, writeFd) = try FileDescriptor . pipe ( )
779
782
let pid = try runDetached (
780
- . path( " /bin/bash " ) ,
783
+ . path( " /bin/sh " ) ,
781
784
arguments: [ " -c " , " echo $$ " ] ,
782
785
output: writeFd
783
786
)
@@ -1046,11 +1049,11 @@ extension FileDescriptor {
1046
1049
1047
1050
// MARK: - Performance Tests
1048
1051
extension SubprocessUnixTests {
1049
- @Test func testConcurrentRun( ) async throws {
1052
+ @Test ( . requiresBash ) func testConcurrentRun( ) async throws {
1050
1053
// Launch as many processes as we can
1051
1054
// Figure out the max open file limit
1052
1055
let limitResult = try await Subprocess . run (
1053
- . path( " /bin/bash " ) ,
1056
+ . path( " /bin/sh " ) ,
1054
1057
arguments: [ " -c " , " ulimit -n " ] ,
1055
1058
output: . string
1056
1059
)
@@ -1075,8 +1078,9 @@ extension SubprocessUnixTests {
1075
1078
let byteCount = 1000
1076
1079
for _ in 0 ..< maxConcurrent {
1077
1080
group. addTask {
1081
+ // This invocation specifically requires bash semantics; sh (on FreeBSD at least) does not consistently support -s in this way
1078
1082
let r = try await Subprocess . run (
1079
- . path ( " /bin/ bash" ) ,
1083
+ . name ( " bash " ) ,
1080
1084
arguments: [
1081
1085
" -sc " , #"echo "$1" && echo "$1" >&2"# , " -- " , String ( repeating: " X " , count: byteCount) ,
1082
1086
] ,
@@ -1099,13 +1103,14 @@ extension SubprocessUnixTests {
1099
1103
}
1100
1104
}
1101
1105
1102
- @Test func testCaptureLongStandardOutputAndError( ) async throws {
1106
+ @Test ( . requiresBash ) func testCaptureLongStandardOutputAndError( ) async throws {
1103
1107
try await withThrowingTaskGroup ( of: Void . self) { group in
1104
1108
var running = 0
1105
1109
for _ in 0 ..< 10 {
1106
1110
group. addTask {
1111
+ // This invocation specifically requires bash semantics; sh (on FreeBSD at least) does not consistently support -s in this way
1107
1112
let r = try await Subprocess . run (
1108
- . path ( " /bin/ bash" ) ,
1113
+ . name ( " bash " ) ,
1109
1114
arguments: [
1110
1115
" -sc " , #"echo "$1" && echo "$1" >&2"# , " -- " , String ( repeating: " X " , count: 100_000 ) ,
1111
1116
] ,
0 commit comments