@@ -82,6 +82,43 @@ final class APIDiffTests: XCTestCase {
8282 #endif
8383 }
8484
85+ func testBreakageAllowlist( ) throws {
86+ #if os(macOS)
87+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
88+ throw XCTSkip ( " swift-api-digester not available " )
89+ }
90+ fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
91+ let packageRoot = prefix. appending ( component: " Bar " )
92+ try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Baz " , " Baz.swift " ) ) {
93+ $0 <<< " public func baz() -> String { \" hello, world! \" } "
94+ }
95+ try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Qux " , " Qux.swift " ) ) {
96+ $0 <<< " public class Qux<T, U> { private let x = 1 } "
97+ }
98+ let customAllowlistPath = packageRoot. appending ( components: " foo " , " allowlist.txt " )
99+ try localFileSystem. writeFileContents ( customAllowlistPath) {
100+ $0 <<< " API breakage: class Qux has generic signature change from <T> to <T, U> \n "
101+ }
102+ XCTAssertThrowsError ( try execute ( [ " experimental-api-diff " , " 1.2.3 " , " -j " , " 2 " ,
103+ " --breakage-allowlist-path " , customAllowlistPath. pathString] ,
104+ packagePath: packageRoot) ) { error in
105+ guard case SwiftPMProductError . executionFailure( error: _, output: let output, stderr: _) = error else {
106+ XCTFail ( " Unexpected error " )
107+ return
108+ }
109+ XCTAssertTrue ( output. contains ( " 1 breaking change detected in Qux " ) )
110+ XCTAssertFalse ( output. contains ( " 💔 API breakage: class Qux has generic signature change from <T> to <T, U> " ) )
111+ XCTAssertTrue ( output. contains ( " 💔 API breakage: var Qux.x has been removed " ) )
112+ XCTAssertTrue ( output. contains ( " 1 breaking change detected in Baz " ) )
113+ XCTAssertTrue ( output. contains ( " 💔 API breakage: func bar() has been removed " ) )
114+ }
115+
116+ }
117+ #else
118+ throw XCTSkip ( " Test unsupported on current platform " )
119+ #endif
120+ }
121+
85122 func testCheckVendedModulesOnly( ) throws {
86123 #if os(macOS)
87124 guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
0 commit comments