Skip to content

Commit eaac195

Browse files
authored
Merge pull request swiftlang#1080 from nkcsgexi/utils-adopter-config
Add a utility function for collecting modules under a given config key. NFC
2 parents 90a2fe0 + c899d9c commit eaac195

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,13 @@ extension Driver {
479479
return []
480480
}
481481

482+
@_spi(Testing) public static func getAllConfiguredModules(withKey: String, _ configs: [AdopterConfig]) -> Set<String> {
483+
let allModules = configs.flatMap {
484+
return $0.key == withKey ? $0.moduleNames : []
485+
}
486+
return Set<String>(allModules)
487+
}
488+
482489
private mutating func addVerifyJobs(emitModuleJob: Job, addJob: (Job) -> Void )
483490
throws {
484491
// Turn this flag on by default with the env var or for public frameworks.

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6017,6 +6017,10 @@ final class SwiftDriverTests: XCTestCase {
60176017
XCTAssertEqual(configs.count, 1)
60186018
XCTAssertEqual(configs[0].key, "SkipFeature1")
60196019
XCTAssertEqual(configs[0].moduleNames, ["foo", "bar"])
6020+
let modules = Driver.getAllConfiguredModules(withKey: "SkipFeature1", configs)
6021+
XCTAssertTrue(modules.contains("foo"))
6022+
XCTAssertTrue(modules.contains("bar"))
6023+
XCTAssertTrue(Driver.getAllConfiguredModules(withKey: "SkipFeature2", configs).isEmpty)
60206024
}
60216025
try withTemporaryFile { file in
60226026
try localFileSystem.writeFileContents(file.path) {

0 commit comments

Comments
 (0)