Skip to content

[Incremental] Properly detect the testing case when honoring -driver-use-frontend-path #407

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 2 commits into from
Dec 11, 2020
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
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,9 @@ extension Driver {
let frontendPath = try AbsolutePath(validating: frontendPathString)
toolchain.overrideToolPath(.swiftCompiler, path: frontendPath)
swiftCompilerPrefixArgs = frontendCommandLine
hasFrontendBeenRedirectedForTesting = FileType.isFrontendExtensionForTesting(frontendPath.extension)
// The tests in Driver/Dependencies redirect the frontend to a python
// script, so don't ask the frontend for target info in that case.
hasFrontendBeenRedirectedForTesting = frontendPath.basename == "Python"
}
} else {
swiftCompilerPrefixArgs = []
Expand Down
6 changes: 2 additions & 4 deletions Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ extension Driver {
case .swift, .image, .dSYM, .dependencies, .autolink, .swiftDocumentation, .swiftInterface,
.privateSwiftInterface, .swiftSourceInfoFile, .diagnostics, .objcHeader, .swiftDeps,
.remap, .tbd, .moduleTrace, .yamlOptimizationRecord, .bitstreamOptimizationRecord, .pcm,
.pch, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies,
.python, nil:
.pch, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies, nil:
return false
}
}
Expand Down Expand Up @@ -358,8 +357,7 @@ extension FileType {
case .swift, .dSYM, .autolink, .dependencies, .swiftDocumentation, .pcm,
.diagnostics, .objcHeader, .image, .swiftDeps, .moduleTrace, .tbd,
.yamlOptimizationRecord, .bitstreamOptimizationRecord, .swiftInterface,
.privateSwiftInterface, .swiftSourceInfoFile, .clangModuleMap, .jsonSwiftArtifacts,
.python:
.privateSwiftInterface, .swiftSourceInfoFile, .clangModuleMap, .jsonSwiftArtifacts:
fatalError("Output type can never be a primary output")
}
}
Expand Down
19 changes: 4 additions & 15 deletions Sources/SwiftDriver/Utilities/FileType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,14 @@ public enum FileType: String, Hashable, CaseIterable, Codable {

/// Clang Module Map
case clangModuleMap = "modulemap"

/// Python script (used for tests)
case python = "py"
}

extension FileType: CustomStringConvertible {
public var description: String {
switch self {
case .swift, .sil, .sib, .image, .dSYM, .dependencies, .autolink,
.swiftModule, .swiftDocumentation, .swiftInterface, .swiftSourceInfoFile, .assembly,
.remap, .tbd, .pcm, .pch, .clangModuleMap, .python:
.remap, .tbd, .pcm, .pch, .clangModuleMap:
return rawValue
case .object:
return "object"
Expand Down Expand Up @@ -214,8 +211,7 @@ extension FileType {
.swiftDocumentation, .pcm, .diagnostics, .objcHeader, .image,
.swiftDeps, .moduleTrace, .tbd, .yamlOptimizationRecord, .bitstreamOptimizationRecord,
.swiftInterface, .privateSwiftInterface, .swiftSourceInfoFile, .jsonDependencies,
.clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies,
.python:
.clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies:
return false
}
}
Expand Down Expand Up @@ -306,8 +302,6 @@ extension FileType {
return "bitstream-opt-record"
case .diagnostics:
return "diagnostics"
case .python:
return "python"
}
}
}
Expand All @@ -319,7 +313,7 @@ extension FileType {
.objcHeader, .autolink, .importedModules, .tbd, .moduleTrace,
.yamlOptimizationRecord, .swiftInterface, .privateSwiftInterface,
.jsonDependencies, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts,
.jsonClangDependencies, .python:
.jsonClangDependencies:
return true
case .image, .object, .dSYM, .pch, .sib, .raw_sib, .swiftModule,
.swiftDocumentation, .swiftSourceInfoFile, .llvmBitcode, .diagnostics,
Expand All @@ -339,13 +333,8 @@ extension FileType {
.swiftSourceInfoFile, .raw_sil, .raw_sib, .diagnostics, .objcHeader, .swiftDeps, .remap,
.importedModules, .tbd, .moduleTrace, .indexData, .yamlOptimizationRecord,
.bitstreamOptimizationRecord, .pcm, .pch, .jsonDependencies, .clangModuleMap,
.jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies, .python:
.jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies:
return false
}
}

static func isFrontendExtensionForTesting(_ extension: String?) -> Bool {
python.rawValue == `extension`
}

}
3 changes: 2 additions & 1 deletion Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,8 @@ final class SwiftDriverTests: XCTestCase {
}
}

let driver = try Driver(args: ["swiftc", "foo1.swift", "bar1.swift", "-enable-batch-mode", "-driver-use-frontend-path", "/dummy.py"], executor: MockExecutor())
var driver = try Driver(args: ["swiftc", "foo1.swift", "bar1.swift", "-enable-batch-mode", "-driver-use-frontend-path", "/Python"], executor: MockExecutor())
try! driver.run(jobs: [])
}

func testSingleThreadedWholeModuleOptimizationCompiles() throws {
Expand Down