@@ -2216,55 +2216,51 @@ final class ExplicitModuleBuildTests: XCTestCase {
22162216
22172217 // Detailed explain (all possible paths)
22182218 do {
2219- var driver = try Driver ( args: [ " swiftc " ,
2220- " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2221- " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2222- " -explicit-module-build " ,
2223- " -module-cache-path " , moduleCachePath. nativePathString ( escaped: true ) ,
2224- " -working-directory " , path. nativePathString ( escaped: true ) ,
2225- " -explain-module-dependency-detailed " , " A " ,
2226- main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting)
2227- let jobs = try driver. planBuild ( )
2228- try driver. run ( jobs: jobs)
2229- XCTAssertTrue ( !driver. diagnosticEngine. diagnostics. isEmpty)
2230- XCTAssertTrue ( driver. diagnosticEngine. diagnostics. contains { $0. behavior == . remark &&
2231- $0. message. text == " Module 'testTraceDependency' depends on 'A' " } )
2232-
2233- for diag in driver. diagnosticEngine. diagnostics {
2234- print ( diag. behavior)
2235- print ( diag. message)
2219+ try assertDriverDiagnostics ( args: [
2220+ " swiftc " ,
2221+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2222+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2223+ " -explicit-module-build " ,
2224+ " -module-cache-path " , moduleCachePath. nativePathString ( escaped: true ) ,
2225+ " -working-directory " , path. nativePathString ( escaped: true ) ,
2226+ " -explain-module-dependency-detailed " , " A " ,
2227+ main. nativePathString ( escaped: true )
2228+ ] + sdkArgumentsForTesting) { driver, diagnostics in
2229+ diagnostics. forbidUnexpected ( . error, . warning, . note, . remark)
2230+
2231+ let jobs = try driver. planBuild ( )
2232+ try driver. run ( jobs: jobs)
2233+
2234+ diagnostics. expect ( . remark( " Module 'testTraceDependency' depends on 'A' " ) )
2235+ diagnostics. expect ( . note( " [testTraceDependency] -> [A] -> [A](ObjC) " ) )
2236+ diagnostics. expect ( . note( " [testTraceDependency] -> [C](ObjC) -> [B](ObjC) -> [A](ObjC) " ) )
22362237 }
2237- XCTAssertEqual ( driver. diagnosticEngine. diagnostics. filter { $0. behavior == . note} . count, 2 )
2238- XCTAssertTrue ( driver. diagnosticEngine. diagnostics. contains { $0. behavior == . note &&
2239- $0. message. text == " [testTraceDependency] -> [A] -> [A](ObjC) " } )
2240- XCTAssertTrue ( driver. diagnosticEngine. diagnostics. contains { $0. behavior == . note &&
2241- $0. message. text == " [testTraceDependency] -> [C](ObjC) -> [B](ObjC) -> [A](ObjC) " } )
22422238 }
22432239
22442240 // Simple explain (first available path)
22452241 do {
2246- var driver = try Driver ( args: [ " swiftc " ,
2247- " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2248- " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2249- " -explicit-module-build " ,
2250- " -module-cache-path " , moduleCachePath. nativePathString ( escaped: true ) ,
2251- " -working-directory " , path. nativePathString ( escaped: true ) ,
2252- " -explain-module-dependency " , " A " ,
2253- main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting)
2254- let jobs = try driver. planBuild ( )
2255- try driver. run ( jobs: jobs)
2256- XCTAssertTrue ( !driver. diagnosticEngine. diagnostics. isEmpty)
2257- XCTAssertTrue ( driver. diagnosticEngine. diagnostics. contains { $0. behavior == . remark &&
2258- $0. message. text == " Module 'testTraceDependency' depends on 'A' " } )
2259-
2260- for diag in driver. diagnosticEngine. diagnostics {
2261- print ( diag. behavior)
2262- print ( diag. message)
2242+ try assertDriverDiagnostics ( args: [
2243+ " swiftc " ,
2244+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2245+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2246+ " -explicit-module-build " ,
2247+ " -module-cache-path " , moduleCachePath. nativePathString ( escaped: true ) ,
2248+ " -working-directory " , path. nativePathString ( escaped: true ) ,
2249+ " -explain-module-dependency " , " A " ,
2250+ main. nativePathString ( escaped: true )
2251+ ] + sdkArgumentsForTesting) { driver, diagnostics in
2252+ diagnostics. forbidUnexpected ( . error, . warning, . note, . remark)
2253+
2254+ let jobs = try driver. planBuild ( )
2255+ try driver. run ( jobs: jobs)
2256+
2257+ diagnostics. expect ( . remark( " Module 'testTraceDependency' depends on 'A' " ) )
2258+ #if os(macOS)
2259+ diagnostics. expect ( . note( " [testTraceDependency] -> [A] -> [A](ObjC) " ) )
2260+ #else
2261+ diagnostics. expect ( . note( " [testTraceDependency] -> [C](ObjC) -> [B](ObjC) -> [A](ObjC) " ) )
2262+ #endif
22632263 }
2264- XCTAssertEqual ( driver. diagnosticEngine. diagnostics. filter { $0. behavior == . note} . count, 1 )
2265- XCTAssertTrue ( driver. diagnosticEngine. diagnostics. contains { $0. behavior == . note &&
2266- ( $0. message. text == " [testTraceDependency] -> [A] -> [A](ObjC) " ||
2267- $0. message. text == " [testTraceDependency] -> [C](ObjC) -> [B](ObjC) -> [A](ObjC) " ) } )
22682264 }
22692265 }
22702266 }
0 commit comments