@@ -1436,6 +1436,18 @@ final class SwiftDriverTests: XCTestCase {
1436
1436
}
1437
1437
}
1438
1438
1439
+ private func clangPathInActiveXcode( ) throws -> AbsolutePath ? {
1440
+ #if !os(macOS)
1441
+ return nil
1442
+ #endif
1443
+ let process = Process ( arguments: [ " xcrun " , " -toolchain " , " default " , " -f " , " clang " ] )
1444
+ try process. launch ( )
1445
+ let result = try process. waitUntilExit ( )
1446
+ guard result. exitStatus == . terminated( code: EXIT_SUCCESS) else { return nil }
1447
+ guard let path = String ( bytes: try result. output. get ( ) , encoding: . utf8) else { return nil }
1448
+ return path. isEmpty ? nil : AbsolutePath ( path. spm_chomp ( ) )
1449
+ }
1450
+
1439
1451
func testCompatibilityLibs( ) throws {
1440
1452
var env = ProcessEnv . vars
1441
1453
env [ " SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK " ] = " 1 "
@@ -1537,6 +1549,30 @@ final class SwiftDriverTests: XCTestCase {
1537
1549
XCTAssertTrue ( cmd. contains ( subsequence: [ . flag( " -force_load " ) , . path( . absolute( path5_1iOS) ) ] ) )
1538
1550
XCTAssertTrue ( cmd. contains ( subsequence: [ . flag( " -force_load " ) , . path( . absolute( pathDynamicReplacementsiOS) ) ] ) )
1539
1551
}
1552
+
1553
+ // libarclite is only relevant on darwin
1554
+ #if os(macOS)
1555
+ do {
1556
+ // Override executive paths and make sure this does not affect the location of the found
1557
+ // libarclite
1558
+ env [ " SWIFT_DRIVER_SWIFTC_EXEC " ] = " /some/path/swiftc "
1559
+ env [ " SWIFT_DRIVER_CLANG_EXEC " ] = " /some/path/clang "
1560
+ guard let clangPathInXcode = try ? clangPathInActiveXcode ( ) else {
1561
+ throw XCTSkip ( )
1562
+ }
1563
+ let clangRelativeArcLite = clangPathInXcode. parentDirectory. parentDirectory
1564
+ . appending ( components: " lib " , " arc " , " libarclite_macosx.a " )
1565
+
1566
+ var driver = try Driver ( args: commonArgs + [ " -target " , " x86_64-apple-macosx10.9 " ] , env: env)
1567
+ let plannedJobs = try driver. planBuild ( )
1568
+
1569
+ XCTAssertEqual ( 3 , plannedJobs. count)
1570
+ let linkJob = plannedJobs [ 2 ]
1571
+ XCTAssertEqual ( linkJob. kind, . link)
1572
+ let cmd = linkJob. commandLine
1573
+ XCTAssertTrue ( cmd. contains ( subsequence: [ . flag( " -force_load " ) , . path( . absolute( clangRelativeArcLite) ) ] ) )
1574
+ }
1575
+ #endif
1540
1576
}
1541
1577
}
1542
1578
0 commit comments