Skip to content

Commit 1e9bfe1

Browse files
authored
Merge pull request #780 from owenv/owenv/migrate-fix
Support migratable features when diagnosing adoption
2 parents 94711fa + 9719a4f commit 1e9bfe1

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,8 +1495,11 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
14951495
let matchingBuildSetting = feature.buildSettings?.first(where: {
14961496
if let macro = try? cbc.scope.namespace.declareBooleanMacro($0) {
14971497
return cbc.scope.evaluate(macro)
1498+
} else if let macro = try? cbc.scope.namespace.declareStringMacro($0) {
1499+
return cbc.scope.evaluate(macro) == "YES"
1500+
} else {
1501+
return false
14981502
}
1499-
return false
15001503
})
15011504
if matchingBuildSetting != nil {
15021505
continue

Tests/SWBBuildSystemTests/SwiftDriverTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4944,6 +4944,45 @@ fileprivate struct SwiftDriverTests: CoreBasedTests {
49444944
}
49454945
}
49464946

4947+
//Reinit the core to invalidate all caching
4948+
tester = try await BuildOperationTester(getCore(), testWorkspace, simulated: false)
4949+
// Test with a setting which has a MIGRATE mode
4950+
do {
4951+
try await tester.fs.writeFileContents(blockListFilePath) { file in
4952+
file <<<
4953+
"""
4954+
{
4955+
"features": {
4956+
"MemberImportVisibility": {
4957+
"level": "warn",
4958+
"buildSettings": ["SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY"],
4959+
"learnMoreURL": "https://www.swift.org/swift-evolution/",
4960+
"moduleExceptions": []
4961+
}
4962+
}
4963+
}
4964+
"""
4965+
}
4966+
4967+
do {
4968+
let params = BuildParameters(configuration: "Debug")
4969+
try await tester.checkBuild(runDestination: .macOS, buildRequest: parameterizedBuildRequest(params)) { results in
4970+
results.checkWarning(.contains("Enabling the Swift language feature 'MemberImportVisibility' will become a requirement in the future; set 'SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES'"))
4971+
results.checkNoDiagnostics()
4972+
}
4973+
try await tester.checkBuild(runDestination: .macOS, buildRequest: cleanRequest) { results in results.checkNoErrors() }
4974+
}
4975+
4976+
do {
4977+
let params = BuildParameters(configuration: "Debug",
4978+
commandLineOverrides: ["SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY": "YES"])
4979+
try await tester.checkBuild(runDestination: .macOS, buildRequest: parameterizedBuildRequest(params)) { results in
4980+
results.checkNoDiagnostics()
4981+
}
4982+
try await tester.checkBuild(runDestination: .macOS, buildRequest: cleanRequest) { results in results.checkNoErrors() }
4983+
}
4984+
}
4985+
49474986
// Test with module exceptions specified in the block list.
49484987
//Reinit the core to invalidate all caching
49494988
tester = try await BuildOperationTester(getCore(), testWorkspace, simulated: false)

0 commit comments

Comments
 (0)