@@ -124,22 +124,22 @@ private struct BasicTests {
124
124
let packagePath = tempDir. appending ( component: " Project " )
125
125
try localFileSystem. createDirectory ( packagePath)
126
126
try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " executable " )
127
- let buildOutput = try sh ( swiftBuild, " --package-path " , packagePath) . stdout
127
+ let packageOutput = try sh ( swiftBuild, " --package-path " , packagePath)
128
128
129
129
// Check the build log.
130
- let checker = StringChecker ( string: buildOutput )
131
- #expect( checker. check ( . regex( " Compiling .*Project.* " ) ) )
132
- #expect( checker. check ( . regex( " Linking .*Project " ) ) )
133
- #expect( checker. check ( . contains( " Build complete " ) ) )
130
+ let checker = StringChecker ( string: packageOutput . stdout )
131
+ #expect( checker. check ( . regex( " Compiling .*Project.* " ) ) , " stdout: ' \( packageOutput . stdout ) ' \n stderr:' \( packageOutput . stderr ) ' " )
132
+ #expect( checker. check ( . regex( " Linking .*Project " ) ) , " stdout: ' \( packageOutput . stdout ) ' \n stderr:' \( packageOutput . stderr ) ' " )
133
+ #expect( checker. check ( . contains( " Build complete " ) ) , " stdout: ' \( packageOutput . stdout ) ' \n stderr:' \( packageOutput . stderr ) ' " )
134
134
135
135
// Verify that the tool was built and works.
136
136
let toolOutput = try sh ( packagePath. appending ( components: " .build " , " debug " , " Project " ) )
137
137
. stdout
138
138
#expect( toolOutput. lowercased ( ) . contains ( " hello, world! " ) )
139
139
140
140
// Check there were no compile errors or warnings.
141
- #expect( buildOutput . contains ( " error " ) == false )
142
- #expect( buildOutput . contains ( " warning " ) == false )
141
+ #expect( packageOutput . stdout . contains ( " error " ) == false )
142
+ #expect( packageOutput . stdout . contains ( " warning " ) == false )
143
143
}
144
144
}
145
145
@@ -151,17 +151,19 @@ private struct BasicTests {
151
151
try localFileSystem. createDirectory ( packagePath)
152
152
withKnownIssue ( " error: no tests found; create a target in the 'Tests' directory " ) {
153
153
try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " executable " )
154
- let testOutput = try sh ( swiftTest, " --package-path " , packagePath) . stdout
154
+ let packageOutput = try sh ( swiftTest, " --package-path " , packagePath, " --vv " )
155
155
156
156
// Check the test log.
157
- let checker = StringChecker ( string: testOutput)
158
- #expect( checker. check ( . regex( " Compiling .*ProjectTests.* " ) ) )
159
- #expect( checker. check ( " Test Suite 'All tests' passed " ) )
160
- #expect( checker. checkNext ( " Executed 1 test " ) )
157
+ let checker = StringChecker ( string: packageOutput. stdout)
158
+ #expect( checker. check ( . regex( " Compiling .*ProjectTests.* " ) ) , " stdout: ' \( packageOutput. stdout) ' \n stderr:' \( packageOutput. stderr) ' " )
159
+ #expect( checker. checkNext ( " Executed 1 test " ) , " stdout: ' \( packageOutput. stdout) ' \n stderr:' \( packageOutput. stderr) ' " )
160
+
161
+ // Check the return code
162
+ #expect( packageOutput. returnCode == . terminated( code: 0 ) )
161
163
162
164
// Check there were no compile errors or warnings.
163
- #expect( testOutput . contains ( " error " ) == false )
164
- #expect( testOutput . contains ( " warning " ) == false )
165
+ #expect( packageOutput . stdout . contains ( " error " ) == false )
166
+ #expect( packageOutput . stdout . contains ( " warning " ) == false )
165
167
}
166
168
}
167
169
}
@@ -192,17 +194,14 @@ private struct BasicTests {
192
194
let packagePath = tempDir. appending ( component: " Project " )
193
195
try localFileSystem. createDirectory ( packagePath)
194
196
try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " library " )
195
- let testOutput = try sh ( swiftTest, " --package-path " , packagePath) . stdout
197
+ let shOutput = try sh ( swiftTest, " --package-path " , packagePath)
196
198
197
- // Check the test log.
198
- let checker = StringChecker ( string: testOutput)
199
- #expect( checker. check ( . contains( " Test Suite 'All tests' started " ) ) )
200
- #expect( checker. check ( . contains( " Test example() passed after " ) ) )
201
- #expect( checker. checkNext ( . contains( " Test run with 1 test passed after " ) ) )
199
+ // Check the return code
200
+ #expect( shOutput. returnCode == . terminated( code: 0 ) )
202
201
203
202
// Check there were no compile errors or warnings.
204
- #expect( testOutput . contains ( " error " ) == false )
205
- #expect( testOutput . contains ( " warning " ) == false )
203
+ #expect( shOutput . stdout . contains ( " error " ) == false )
204
+ #expect( shOutput . stdout . contains ( " warning " ) == false )
206
205
}
207
206
}
208
207
@@ -248,11 +247,11 @@ private struct BasicTests {
248
247
#expect( buildOutput. contains ( " Build complete " ) )
249
248
250
249
// Verify that the tool exists and works.
251
- let toolOutput = try sh (
250
+ let shOutput = try sh (
252
251
packagePath. appending ( components: " .build " , " debug " , " special tool " )
253
252
) . stdout
254
253
255
- #expect( toolOutput == " HI \( ProcessInfo . EOL) " )
254
+ #expect( shOutput == " HI \( ProcessInfo . EOL) " )
256
255
}
257
256
}
258
257
@@ -281,17 +280,20 @@ private struct BasicTests {
281
280
"""
282
281
)
283
282
)
284
- let ( runOutput , runError ) = try sh (
283
+ let shOutput = try sh (
285
284
swiftRun, " --package-path " , packagePath, " secho " , " 1 " , #""two""#
286
285
)
287
286
288
287
// Check the run log.
289
- let checker = StringChecker ( string: runError)
290
- #expect( checker. check ( . regex( " Compiling .*secho.* " ) ) )
291
- #expect( checker. check ( . regex( " Linking .*secho " ) ) )
292
- #expect( checker. check ( . contains( " Build of product 'secho' complete " ) ) )
288
+ let checker = StringChecker ( string: shOutput. stderr)
289
+ #expect( checker. check ( . regex( " Compiling .*secho.* " ) ) , " stdout: ' \( shOutput. stdout) ' \n stderr:' \( shOutput. stderr) ' " )
290
+ #expect( checker. check ( . regex( " Linking .*secho " ) ) , " stdout: ' \( shOutput. stdout) ' \n stderr:' \( shOutput. stderr) ' " )
291
+ #expect( checker. check ( . contains( " Build of product 'secho' complete " ) ) , " stdout: ' \( shOutput. stdout) ' \n stderr:' \( shOutput. stderr) ' " )
292
+
293
+ #expect( shOutput. stdout == " 1 \" two \" \( ProcessInfo . EOL) " )
293
294
294
- #expect( runOutput == " 1 \" two \" \( ProcessInfo . EOL) " )
295
+ // Check the return code
296
+ #expect( shOutput. returnCode == . terminated( code: 0 ) )
295
297
}
296
298
}
297
299
@@ -318,16 +320,16 @@ private struct BasicTests {
318
320
"""
319
321
)
320
322
)
321
- let testOutput = try sh (
323
+ let shOutput = try sh (
322
324
swiftTest, " --package-path " , packagePath, " --filter " , " MyTests.* " , " --skip " ,
323
- " testBaz "
324
- ) . stderr
325
+ " testBaz " , " --vv "
326
+ )
325
327
326
328
// Check the test log.
327
- let checker = StringChecker ( string: testOutput )
328
- #expect( checker. check ( . contains( " Test Suite 'MyTests' started " ) ) )
329
- #expect( checker. check ( . contains( " Test Suite 'MyTests' passed " ) ) )
330
- #expect( checker. check ( . contains( " Executed 2 tests, with 0 failures " ) ) )
329
+ let checker = StringChecker ( string: shOutput . stderr )
330
+ #expect( checker. check ( . contains( " Test Suite 'MyTests' started " ) ) , " stdout: ' \( shOutput . stdout ) ' \n stderr:' \( shOutput . stderr ) ' " )
331
+ #expect( checker. check ( . contains( " Test Suite 'MyTests' passed " ) ) , " stdout: ' \( shOutput . stdout ) ' \n stderr:' \( shOutput . stderr ) ' " )
332
+ #expect( checker. check ( . contains( " Executed 2 tests, with 0 failures " ) ) , " stdout: ' \( shOutput . stdout ) ' \n stderr:' \( shOutput . stderr ) ' " )
331
333
}
332
334
}
333
335
@@ -410,15 +412,15 @@ private struct BasicTests {
410
412
)
411
413
)
412
414
413
- let testOutput = try sh (
414
- swiftTest, " --package-path " , packagePath, " --filter " , " MyTests.* "
415
- ) . stdout
415
+ let shOutput = try sh (
416
+ swiftTest, " --package-path " , packagePath, " --filter " , " MyTests.* " , " --vv "
417
+ )
416
418
417
419
// Check the test log.
418
- let checker = StringChecker ( string: testOutput )
419
- #expect( checker. check ( . contains( " Test Suite 'MyTests' started " ) ) )
420
- #expect( checker. check ( . contains( " Test Suite 'MyTests' passed " ) ) )
421
- #expect( checker. check ( . contains( " Executed 2 tests, with 0 failures " ) ) )
420
+ let checker = StringChecker ( string: shOutput . stdout )
421
+ #expect( checker. check ( . contains( " Test Suite 'MyTests' started " ) ) , " stdout: ' \( shOutput . stdout ) ' \n stderr:' \( shOutput . stderr ) ' " )
422
+ #expect( checker. check ( . contains( " Test Suite 'MyTests' passed " ) ) , " stdout: ' \( shOutput . stdout ) ' \n stderr:' \( shOutput . stderr ) ' " )
423
+ #expect( checker. check ( . contains( " Executed 2 tests, with 0 failures " ) ) , " stdout: ' \( shOutput . stdout ) ' \n stderr:' \( shOutput . stderr ) ' " )
422
424
}
423
425
}
424
426
}
0 commit comments