Skip to content

Commit 7766798

Browse files
author
David Ungar
authored
Merge pull request #407 from davidungar/honor-frontend-path-2
[Incremental] Properly detect the testing case when honoring -driver-use-frontend-path
2 parents 52bfaa7 + 7b8c7e7 commit 7766798

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,9 @@ extension Driver {
20752075
let frontendPath = try AbsolutePath(validating: frontendPathString)
20762076
toolchain.overrideToolPath(.swiftCompiler, path: frontendPath)
20772077
swiftCompilerPrefixArgs = frontendCommandLine
2078-
hasFrontendBeenRedirectedForTesting = FileType.isFrontendExtensionForTesting(frontendPath.extension)
2078+
// The tests in Driver/Dependencies redirect the frontend to a python
2079+
// script, so don't ask the frontend for target info in that case.
2080+
hasFrontendBeenRedirectedForTesting = frontendPath.basename == "Python"
20792081
}
20802082
} else {
20812083
swiftCompilerPrefixArgs = []

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ extension Driver {
7979
case .swift, .image, .dSYM, .dependencies, .autolink, .swiftDocumentation, .swiftInterface,
8080
.privateSwiftInterface, .swiftSourceInfoFile, .diagnostics, .objcHeader, .swiftDeps,
8181
.remap, .tbd, .moduleTrace, .yamlOptimizationRecord, .bitstreamOptimizationRecord, .pcm,
82-
.pch, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies,
83-
.python, nil:
82+
.pch, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies, nil:
8483
return false
8584
}
8685
}
@@ -358,8 +357,7 @@ extension FileType {
358357
case .swift, .dSYM, .autolink, .dependencies, .swiftDocumentation, .pcm,
359358
.diagnostics, .objcHeader, .image, .swiftDeps, .moduleTrace, .tbd,
360359
.yamlOptimizationRecord, .bitstreamOptimizationRecord, .swiftInterface,
361-
.privateSwiftInterface, .swiftSourceInfoFile, .clangModuleMap, .jsonSwiftArtifacts,
362-
.python:
360+
.privateSwiftInterface, .swiftSourceInfoFile, .clangModuleMap, .jsonSwiftArtifacts:
363361
fatalError("Output type can never be a primary output")
364362
}
365363
}

Sources/SwiftDriver/Utilities/FileType.swift

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,14 @@ public enum FileType: String, Hashable, CaseIterable, Codable {
130130

131131
/// Clang Module Map
132132
case clangModuleMap = "modulemap"
133-
134-
/// Python script (used for tests)
135-
case python = "py"
136133
}
137134

138135
extension FileType: CustomStringConvertible {
139136
public var description: String {
140137
switch self {
141138
case .swift, .sil, .sib, .image, .dSYM, .dependencies, .autolink,
142139
.swiftModule, .swiftDocumentation, .swiftInterface, .swiftSourceInfoFile, .assembly,
143-
.remap, .tbd, .pcm, .pch, .clangModuleMap, .python:
140+
.remap, .tbd, .pcm, .pch, .clangModuleMap:
144141
return rawValue
145142
case .object:
146143
return "object"
@@ -214,8 +211,7 @@ extension FileType {
214211
.swiftDocumentation, .pcm, .diagnostics, .objcHeader, .image,
215212
.swiftDeps, .moduleTrace, .tbd, .yamlOptimizationRecord, .bitstreamOptimizationRecord,
216213
.swiftInterface, .privateSwiftInterface, .swiftSourceInfoFile, .jsonDependencies,
217-
.clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies,
218-
.python:
214+
.clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies:
219215
return false
220216
}
221217
}
@@ -306,8 +302,6 @@ extension FileType {
306302
return "bitstream-opt-record"
307303
case .diagnostics:
308304
return "diagnostics"
309-
case .python:
310-
return "python"
311305
}
312306
}
313307
}
@@ -319,7 +313,7 @@ extension FileType {
319313
.objcHeader, .autolink, .importedModules, .tbd, .moduleTrace,
320314
.yamlOptimizationRecord, .swiftInterface, .privateSwiftInterface,
321315
.jsonDependencies, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts,
322-
.jsonClangDependencies, .python:
316+
.jsonClangDependencies:
323317
return true
324318
case .image, .object, .dSYM, .pch, .sib, .raw_sib, .swiftModule,
325319
.swiftDocumentation, .swiftSourceInfoFile, .llvmBitcode, .diagnostics,
@@ -339,13 +333,8 @@ extension FileType {
339333
.swiftSourceInfoFile, .raw_sil, .raw_sib, .diagnostics, .objcHeader, .swiftDeps, .remap,
340334
.importedModules, .tbd, .moduleTrace, .indexData, .yamlOptimizationRecord,
341335
.bitstreamOptimizationRecord, .pcm, .pch, .jsonDependencies, .clangModuleMap,
342-
.jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies, .python:
336+
.jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies:
343337
return false
344338
}
345339
}
346-
347-
static func isFrontendExtensionForTesting(_ extension: String?) -> Bool {
348-
python.rawValue == `extension`
349-
}
350-
351340
}

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,8 @@ final class SwiftDriverTests: XCTestCase {
14951495
}
14961496
}
14971497

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

15011502
func testSingleThreadedWholeModuleOptimizationCompiles() throws {

0 commit comments

Comments
 (0)