@@ -25,25 +25,6 @@ import _InternalTestSupport
2525import Workspace
2626import Testing
2727
28- fileprivate func expectThrowsCommandExecutionError< T> (
29- _ expression: @autoclosure ( ) async throws -> T ,
30- sourceLocation: SourceLocation = #_sourceLocation,
31- _ errorHandler: ( _ error: CommandExecutionError ) throws -> Void = { _ in }
32- ) async rethrows {
33- let error = await #expect( throws: SwiftPMError . self, sourceLocation: sourceLocation) {
34- try await expression ( )
35- }
36-
37- guard case . executionFailure( let processError, let stdout, let stderr) = error,
38- case AsyncProcessResult . Error . nonZeroExit( let processResult) = processError,
39- processResult. exitStatus != . terminated( code: 0 ) else {
40- Issue . record ( " Unexpected error type: \( error? . interpolationDescription) " , sourceLocation: sourceLocation)
41- return
42- }
43- try errorHandler ( CommandExecutionError ( result: processResult, stdout: stdout, stderr: stderr) )
44- }
45-
46-
4728extension Trait where Self == Testing . ConditionTrait {
4829 public static var requiresAPIDigester : Self {
4930 enabled ( " This test requires a toolchain with swift-api-digester " ) {
@@ -81,7 +62,7 @@ struct APIDiffTests {
8162 packageRoot. appending ( " Foo.swift " ) ,
8263 string: " public let foo = 42 "
8364 )
84- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
65+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
8566 #expect( !error. stdout. isEmpty)
8667 }
8768 }
@@ -96,7 +77,7 @@ struct APIDiffTests {
9677 packageRoot. appending ( " Foo.swift " ) ,
9778 string: " public let foo = 42 "
9879 )
99- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
80+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
10081 #expect( error. stdout. contains ( " 1 breaking change detected in Foo " ) )
10182 #expect( error. stdout. contains ( " 💔 API breakage: func foo() has been removed " ) )
10283 }
@@ -119,7 +100,7 @@ struct APIDiffTests {
119100 packageRoot. appending ( components: " Sources " , " Qux " , " Qux.swift " ) ,
120101 string: " public class Qux<T, U> { private let x = 1 } "
121102 )
122- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
103+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
123104 withKnownIssue {
124105 #expect( error. stdout. contains ( " 2 breaking changes detected in Qux " ) )
125106 #expect( error. stdout. contains ( " 💔 API breakage: class Qux has generic signature change from <T> to <T, U> " ) )
@@ -154,7 +135,7 @@ struct APIDiffTests {
154135 customAllowlistPath,
155136 string: " API breakage: class Qux has generic signature change from <T> to <T, U> \n "
156137 )
157- try await expectThrowsCommandExecutionError (
138+ await expectThrowsCommandExecutionError (
158139 try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " , " --breakage-allowlist-path " , customAllowlistPath. pathString] ,
159140 packagePath: packageRoot, buildSystem: buildSystem)
160141 ) { error in
@@ -277,7 +258,7 @@ struct APIDiffTests {
277258 }
278259
279260 // Test diagnostics
280- try await expectThrowsCommandExecutionError (
261+ await expectThrowsCommandExecutionError (
281262 try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " , " --targets " , " NotATarget " , " Exec " , " --products " , " NotAProduct " , " Exec " ] ,
282263 packagePath: packageRoot, buildSystem: buildSystem)
283264 ) { error in
@@ -305,13 +286,13 @@ struct APIDiffTests {
305286 }
306287 """
307288 )
308- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
289+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
309290 #expect( error. stdout. contains ( " 1 breaking change detected in Bar " ) )
310291 #expect( error. stdout. contains ( " 💔 API breakage: func bar() has return type change from Swift.Int to Swift.String " ) )
311292 }
312293
313294 // Report an error if we explicitly ask to diff a C-family target
314- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " , " --targets " , " Foo " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
295+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " , " --targets " , " Foo " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
315296 #expect( error. stderr. contains ( " error: 'Foo' is not a Swift language target " ) )
316297 }
317298 }
@@ -413,7 +394,7 @@ struct APIDiffTests {
413394 func testBadTreeish( buildSystem: BuildSystemProvider . Kind ) async throws {
414395 try await fixture ( name: " Miscellaneous/APIDiff/ " ) { fixturePath in
415396 let packageRoot = fixturePath. appending ( " Foo " )
416- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 7.8.9 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
397+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 7.8.9 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
417398 #expect( error. stderr. contains ( " error: Couldn’t get revision " ) )
418399 }
419400 }
@@ -433,7 +414,7 @@ struct APIDiffTests {
433414 )
434415 try repo. stage ( file: " Foo.swift " )
435416 try repo. commit ( message: " Add foo " )
436- try await expectThrowsCommandExecutionError (
417+ await expectThrowsCommandExecutionError (
437418 try await execute ( [ " diagnose-api-breaking-changes " , " main " , " --baseline-dir " , baselineDir. pathString] ,
438419 packagePath: packageRoot,
439420 buildSystem: buildSystem)
@@ -473,7 +454,7 @@ struct APIDiffTests {
473454 let repo = GitRepository ( path: packageRoot)
474455 let revision = try repo. resolveRevision ( identifier: " 1.2.3 " )
475456
476- try await expectThrowsCommandExecutionError (
457+ await expectThrowsCommandExecutionError (
477458 try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " , " --baseline-dir " , baselineDir. pathString] , packagePath: packageRoot, buildSystem: buildSystem)
478459 ) { error in
479460 #expect( error. stdout. contains ( " 1 breaking change detected in Foo " ) )
@@ -541,7 +522,7 @@ struct APIDiffTests {
541522 // Accomodate filesystems with low resolution timestamps
542523 try await Task . sleep ( for: . seconds( 1 ) )
543524
544- try await expectThrowsCommandExecutionError (
525+ await expectThrowsCommandExecutionError (
545526 try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ,
546527 " --baseline-dir " , baselineDir. pathString, " --regenerate-baseline " ] ,
547528 packagePath: packageRoot,
@@ -556,7 +537,7 @@ struct APIDiffTests {
556537
557538 @Test ( arguments: SupportedBuildSystemOnAllPlatforms)
558539 func testOldName( buildSystem: BuildSystemProvider . Kind ) async throws {
559- try await expectThrowsCommandExecutionError ( try await execute ( [ " experimental-api-diff " , " 1.2.3 " , " --regenerate-baseline " ] , packagePath: nil , buildSystem: buildSystem) ) { error in
540+ await expectThrowsCommandExecutionError ( try await execute ( [ " experimental-api-diff " , " 1.2.3 " , " --regenerate-baseline " ] , packagePath: nil , buildSystem: buildSystem) ) { error in
560541 #expect( error. stdout. contains ( " `swift package experimental-api-diff` has been renamed to `swift package diagnose-api-breaking-changes` " ) )
561542 }
562543 }
@@ -565,7 +546,7 @@ struct APIDiffTests {
565546 func testBrokenAPIDiff( buildSystem: BuildSystemProvider . Kind ) async throws {
566547 try await fixture ( name: " Miscellaneous/APIDiff/ " ) { fixturePath in
567548 let packageRoot = fixturePath. appending ( " BrokenPkg " )
568- try await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
549+ await expectThrowsCommandExecutionError ( try await execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot, buildSystem: buildSystem) ) { error in
569550 let expectedError : String
570551 if buildSystem == . swiftbuild {
571552 expectedError = " error: Build failed "
0 commit comments