@@ -1190,10 +1190,12 @@ struct TestCommandTests {
11901190
11911191 #expect( error == ExitCode . failure, " Expected ExitCode.failure, got \( String ( describing: error) ) " )
11921192
1193- let errorDescription = outputStream. bytes. description
1193+ // The output stream is written to asynchronously on a DispatchQueue and can
1194+ // receive output after the command has thrown.
1195+ let found = try await waitForOutputStreamToContain ( outputStream, " --debugger cannot be used with --parallel " )
11941196 #expect(
1195- errorDescription . contains ( " --debugger cannot be used with --parallel " ) ,
1196- " Expected error about incompatible flags, got: \( errorDescription ) "
1197+ found ,
1198+ " Expected error about incompatible flags, got: \( outputStream . bytes . description ) "
11971199 )
11981200 }
11991201
@@ -1209,11 +1211,11 @@ struct TestCommandTests {
12091211
12101212 #expect( error == ExitCode . failure, " Expected ExitCode.failure, got \( String ( describing: error) ) " )
12111213
1212- let errorDescription = outputStream. bytes. description
12131214 // Should hit the --parallel error first since validation is done in order
1215+ let found = try await waitForOutputStreamToContain ( outputStream, " --debugger cannot be used with --parallel " )
12141216 #expect(
1215- errorDescription . contains ( " --debugger cannot be used with --parallel " ) ,
1216- " Expected error about incompatible flags, got: \( errorDescription ) "
1217+ found ,
1218+ " Expected error about incompatible flags, got: \( outputStream . bytes . description ) "
12171219 )
12181220 }
12191221
@@ -1229,10 +1231,10 @@ struct TestCommandTests {
12291231
12301232 #expect( error == ExitCode . failure, " Expected ExitCode.failure, got \( String ( describing: error) ) " )
12311233
1232- let errorDescription = outputStream. bytes . description
1234+ let found = try await waitForOutputStreamToContain ( outputStream, " --debugger cannot be used with --num-workers " )
12331235 #expect(
1234- errorDescription . contains ( " --debugger cannot be used with --num-workers " ) ,
1235- " Expected error about incompatible flags, got: \( errorDescription ) "
1236+ found ,
1237+ " Expected error about incompatible flags, got: \( outputStream . bytes . description ) "
12361238 )
12371239 }
12381240
@@ -1248,10 +1250,10 @@ struct TestCommandTests {
12481250
12491251 #expect( error == ExitCode . failure, " Expected ExitCode.failure, got \( String ( describing: error) ) " )
12501252
1251- let errorDescription = outputStream. bytes . description
1253+ let found = try await waitForOutputStreamToContain ( outputStream, " --debugger cannot be used with --list-tests " )
12521254 #expect(
1253- errorDescription . contains ( " --debugger cannot be used with --list-tests " ) ,
1254- " Expected error about incompatible flags, got: \( errorDescription ) "
1255+ found ,
1256+ " Expected error about incompatible flags, got: \( outputStream . bytes . description ) "
12551257 )
12561258 }
12571259
@@ -1267,10 +1269,10 @@ struct TestCommandTests {
12671269
12681270 #expect( error == ExitCode . failure, " Expected ExitCode.failure, got \( String ( describing: error) ) " )
12691271
1270- let errorDescription = outputStream. bytes . description
1272+ let found = try await waitForOutputStreamToContain ( outputStream, " --debugger cannot be used with --show-codecov-path " )
12711273 #expect(
1272- errorDescription . contains ( " --debugger cannot be used with --show-codecov-path " ) ,
1273- " Expected error about incompatible flags, got: \( errorDescription ) "
1274+ found ,
1275+ " Expected error about incompatible flags, got: \( outputStream . bytes . description ) "
12741276 )
12751277 }
12761278
@@ -1286,10 +1288,10 @@ struct TestCommandTests {
12861288
12871289 #expect( error == ExitCode . failure, " Expected ExitCode.failure, got \( String ( describing: error) ) " )
12881290
1289- let errorDescription = outputStream. bytes . description
1291+ let found = try await waitForOutputStreamToContain ( outputStream, " --debugger cannot be used with release configuration " )
12901292 #expect(
1291- errorDescription . contains ( " --debugger cannot be used with release configuration " ) ,
1292- " Expected error about incompatible flags, got: \( errorDescription ) "
1293+ found ,
1294+ " Expected error about incompatible flags, got: \( outputStream . bytes . description ) "
12931295 )
12941296 }
12951297
0 commit comments