Skip to content

[Test Only] Adapt testExplicitLinkLibraries to use opt-in scanner validation mechanism on supporting compilers #1673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SwiftOptions/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<path>", helpText: "Remap paths within SDK reported by dependency scanner")
public static let scannerPrefixMapToolchain: Option = Option("-scanner-prefix-map-toolchain", .separate, attributes: [], metaVar: "<path>", helpText: "Remap paths within toolchain directory reported by dependency scanner")
public static let scannerPrefixMap: Option = Option("-scanner-prefix-map", .separate, attributes: [.frontend], metaVar: "<prefix=replacement>", helpText: "Remap paths reported by dependency scanner")
Expand Down Expand Up @@ -1616,6 +1617,7 @@ extension Option {
Option.saveOptimizationRecord,
Option.saveTemps,
Option.scanDependencies,
Option.scannerModuleValidation,
Option.scannerPrefixMapSdk,
Option.scannerPrefixMapToolchain,
Option.scannerPrefixMap,
Expand Down
18 changes: 12 additions & 6 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down