Skip to content

Commit

Permalink
Put default interface verifier behind an env var
Browse files Browse the repository at this point in the history
Without setting this variable, we won't enable module interface verifier unless
explicitly asked to.
  • Loading branch information
nkcsgexi committed Aug 11, 2021
1 parent 17a1f92 commit 33177f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Sources/SwiftDriver/Jobs/Planning.swift
Expand Up @@ -439,6 +439,12 @@ extension Driver {
default: false)
else { return }

// FIXME: remove this when we are confident to enable interface verification
// by default.
if env["ENABLE_DEFAULT_INTERFACE_VERIFIER"] == nil &&
!parsedOptions.hasArgument(.verifyEmittedModuleInterface) {
return
}
func addVerifyJob(forPrivate: Bool) throws {
let isNeeded =
forPrivate
Expand Down
22 changes: 17 additions & 5 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Expand Up @@ -3940,6 +3940,8 @@ final class SwiftDriverTests: XCTestCase {

func testVerifyEmittedInterfaceJob() throws {
// Evolution enabled
var envVars = ProcessEnv.vars
envVars["ENABLE_DEFAULT_INTERFACE_VERIFIER"] = "YES"
do {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface",
Expand All @@ -3965,7 +3967,7 @@ final class SwiftDriverTests: XCTestCase {
// No Evolution
do {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface", "-verify-emitted-module-interface"])
"foo", "-emit-module-interface", "-verify-emitted-module-interface"], env: envVars)
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 2)
}
Expand All @@ -3975,7 +3977,7 @@ final class SwiftDriverTests: XCTestCase {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface",
"-enable-library-evolution",
"-no-verify-emitted-module-interface"])
"-no-verify-emitted-module-interface"], env: envVars)
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 2)
}
Expand All @@ -3985,18 +3987,28 @@ final class SwiftDriverTests: XCTestCase {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface",
"-enable-library-evolution",
"-no-emit-module-separately"])
"-no-emit-module-separately"], env: envVars)
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 2)
}

// Emit-module separately
// Disabled when no "ENABLE_DEFAULT_INTERFACE_VERIFIER" found in the environment
do {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface",
"-enable-library-evolution",
"-experimental-emit-module-separately"])
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 1)
}

// Emit-module separately
do {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface",
"-enable-library-evolution",
"-experimental-emit-module-separately"], env: envVars)
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 2)
let emitJob = plannedJobs[0]
let verifyJob = plannedJobs[1]
Expand All @@ -4015,7 +4027,7 @@ final class SwiftDriverTests: XCTestCase {
var driver = try Driver(args: ["swiftc", "foo.swift", "-emit-module", "-module-name",
"foo", "-emit-module-interface",
"-enable-library-evolution",
"-whole-module-optimization"])
"-whole-module-optimization"], env: envVars)
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 2)
let emitJob = plannedJobs[0]
Expand Down

0 comments on commit 33177f7

Please sign in to comment.