From 97573b0f2d2574da42f7208065d2c1eef5f9a11d Mon Sep 17 00:00:00 2001 From: Artem Chikin Date: Tue, 30 Jul 2024 09:45:48 -0700 Subject: [PATCH] [Test Only] Adapt 'testExplicitLinkLibraries' to use opt-in scanner validation mehanism on supporting compilers --- Sources/SwiftOptions/Options.swift | 2 ++ .../ExplicitModuleBuildTests.swift | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftOptions/Options.swift b/Sources/SwiftOptions/Options.swift index 15f0f2199..8ab452e64 100644 --- a/Sources/SwiftOptions/Options.swift +++ b/Sources/SwiftOptions/Options.swift @@ -745,6 +745,7 @@ extension Option { public static let saveOptimizationRecord: Option = Option("-save-optimization-record", .flag, attributes: [.frontend], helpText: "Generate a YAML optimization record file") public static let saveTemps: Option = Option("-save-temps", .flag, attributes: [.noInteractive, .doesNotAffectIncrementalBuild], helpText: "Save intermediate compilation results") public static let scanDependencies: Option = Option("-scan-dependencies", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Scan dependencies of the given Swift sources", group: .modes) + public static let scannerModuleValidation: Option = Option("-scanner-module-validation", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Validate binary modules in the dependency scanner") public static let scannerPrefixMapSdk: Option = Option("-scanner-prefix-map-sdk", .separate, attributes: [], metaVar: "", helpText: "Remap paths within SDK reported by dependency scanner") public static let scannerPrefixMapToolchain: Option = Option("-scanner-prefix-map-toolchain", .separate, attributes: [], metaVar: "", helpText: "Remap paths within toolchain directory reported by dependency scanner") public static let scannerPrefixMap: Option = Option("-scanner-prefix-map", .separate, attributes: [.frontend], metaVar: "", helpText: "Remap paths reported by dependency scanner") @@ -1616,6 +1617,7 @@ extension Option { Option.saveOptimizationRecord, Option.saveTemps, Option.scanDependencies, + Option.scannerModuleValidation, Option.scannerPrefixMapSdk, Option.scannerPrefixMapToolchain, Option.scannerPrefixMap, diff --git a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift index 2c5e1d596..655ba514d 100644 --- a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift +++ b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift @@ -374,12 +374,18 @@ final class ExplicitModuleBuildTests: XCTestCase { throw XCTSkip("libSwiftScan does not support link library reporting.") } - var driver = try Driver(args: ["swiftc", - "-I", cHeadersPath.nativePathString(escaped: true), - "-I", swiftModuleInterfacesPath.nativePathString(escaped: true), - "-explicit-module-build", - "-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true), - main.nativePathString(escaped: true)] + sdkArgumentsForTesting) + var args = ["swiftc", + "-I", cHeadersPath.nativePathString(escaped: true), + "-I", swiftModuleInterfacesPath.nativePathString(escaped: true), + "-explicit-module-build", + "-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true), + main.nativePathString(escaped: true)] + sdkArgumentsForTesting + var driver = try Driver(args: args) + // If this is a supported flow, then it is currently required for this test + if driver.isFrontendArgSupported(.scannerModuleValidation) { + driver = try Driver(args: args + ["-scanner-module-validation"]) + } + let _ = try driver.planBuild() let dependencyGraph = try XCTUnwrap(driver.explicitDependencyBuildPlanner?.dependencyGraph)