Skip to content

Commit bc04f85

Browse files
committed
[Test Only] Adapt 'testExplicitLinkLibraries' to use opt-in scanner validation mehanism on supporting compilers
1 parent 4e5cfa4 commit bc04f85

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ extension Option {
745745
public static let saveOptimizationRecord: Option = Option("-save-optimization-record", .flag, attributes: [.frontend], helpText: "Generate a YAML optimization record file")
746746
public static let saveTemps: Option = Option("-save-temps", .flag, attributes: [.noInteractive, .doesNotAffectIncrementalBuild], helpText: "Save intermediate compilation results")
747747
public static let scanDependencies: Option = Option("-scan-dependencies", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Scan dependencies of the given Swift sources", group: .modes)
748+
public static let scannerModuleValidation: Option = Option("-scanner-module-validation", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Validate binary modules in the dependency scanner")
748749
public static let scannerPrefixMapSdk: Option = Option("-scanner-prefix-map-sdk", .separate, attributes: [], metaVar: "<path>", helpText: "Remap paths within SDK reported by dependency scanner")
749750
public static let scannerPrefixMapToolchain: Option = Option("-scanner-prefix-map-toolchain", .separate, attributes: [], metaVar: "<path>", helpText: "Remap paths within toolchain directory reported by dependency scanner")
750751
public static let scannerPrefixMap: Option = Option("-scanner-prefix-map", .separate, attributes: [.frontend], metaVar: "<prefix=replacement>", helpText: "Remap paths reported by dependency scanner")
@@ -1616,6 +1617,7 @@ extension Option {
16161617
Option.saveOptimizationRecord,
16171618
Option.saveTemps,
16181619
Option.scanDependencies,
1620+
Option.scannerModuleValidation,
16191621
Option.scannerPrefixMapSdk,
16201622
Option.scannerPrefixMapToolchain,
16211623
Option.scannerPrefixMap,

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,18 @@ final class ExplicitModuleBuildTests: XCTestCase {
374374
throw XCTSkip("libSwiftScan does not support link library reporting.")
375375
}
376376

377-
var driver = try Driver(args: ["swiftc",
378-
"-I", cHeadersPath.nativePathString(escaped: true),
379-
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
380-
"-explicit-module-build",
381-
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
382-
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
377+
var args = ["swiftc",
378+
"-I", cHeadersPath.nativePathString(escaped: true),
379+
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
380+
"-explicit-module-build",
381+
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
382+
main.nativePathString(escaped: true)] + sdkArgumentsForTesting
383+
var driver = try Driver(args: args)
384+
// If this is a supported flow, then it is currently required for this test
385+
if driver.isFrontendArgSupported(.scannerModuleValidation) {
386+
driver = try Driver(args: args + ["-scanner-module-validation"])
387+
}
388+
383389
let _ = try driver.planBuild()
384390
let dependencyGraph = try XCTUnwrap(driver.explicitDependencyBuildPlanner?.dependencyGraph)
385391

0 commit comments

Comments
 (0)