Skip to content

Commit f3d4d83

Browse files
committed
add test for collecting Swift adopters
1 parent a43e899 commit f3d4d83

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Sources/SwiftDriver/Jobs/PrebuiltModulesJob.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,19 @@ public struct PrebuiltModuleInput {
243243
}
244244

245245
public class SwiftAdopter: Codable {
246-
let name: String
247-
let moduleDir: String
248-
let hasInterface: Bool
249-
let hasModule: Bool
250-
let isFramework: Bool
251-
let isPrivateFramework: Bool
246+
public let name: String
247+
public let moduleDir: String
248+
public let hasInterface: Bool
249+
public let hasModule: Bool
250+
public let isFramework: Bool
251+
public let isPrivate: Bool
252252
init(_ name: String, _ moduleDir: AbsolutePath, _ hasInterface: AbsolutePath?, _ hasModule: AbsolutePath?) {
253253
self.name = name
254254
self.moduleDir = SwiftAdopter.relativeToSDK(moduleDir)
255255
self.hasInterface = hasInterface != nil
256256
self.hasModule = hasModule != nil
257257
self.isFramework = self.moduleDir.contains("\(name).framework")
258-
self.isPrivateFramework = self.moduleDir.contains("PrivateFrameworks")
258+
self.isPrivate = self.moduleDir.contains("PrivateFrameworks")
259259
}
260260
static func relativeToSDK(_ fullPath: AbsolutePath) -> String {
261261
var SDKDir: AbsolutePath = fullPath

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,5 +1536,17 @@ final class ExplicitModuleBuildTests: XCTestCase {
15361536
XCTAssertTrue(compileJobs.allSatisfy { $0.commandLine.contains(.path(VirtualPath.absolute(PFPath))) })
15371537
}
15381538
}
1539+
func testCollectSwiftAdopters() throws {
1540+
let mockSDKPath = testInputsPath.appending(component: "mock-sdk.Internal.sdk")
1541+
let mockSDKPathStr: String = mockSDKPath.pathString
1542+
let collector = try SDKPrebuiltModuleInputsCollector(VirtualPath(path: mockSDKPathStr).absolutePath!, DiagnosticsEngine())
1543+
let adopters = try collector.collectSwiftInterfaceMap().adopters
1544+
XCTAssertTrue(!adopters.isEmpty)
1545+
let A = adopters.first {$0.name == "A"}!
1546+
XCTAssertFalse(A.isFramework)
1547+
XCTAssertFalse(A.isPrivate)
1548+
XCTAssertFalse(A.hasModule)
1549+
XCTAssertTrue(A.hasInterface)
1550+
}
15391551
#endif
15401552
}

0 commit comments

Comments
 (0)