Skip to content

Commit f463d12

Browse files
author
David Ungar
committed
Only for testing if .py
1 parent db5cb94 commit f463d12

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,23 +2062,24 @@ extension Driver {
20622062

20632063
// Find the Swift compiler executable.
20642064
let swiftCompilerPrefixArgs: [String]
2065+
let hasFrontendBeenRedirectedForTesting: Bool
20652066
if let frontendPath = parsedOptions.getLastArgument(.driverUseFrontendPath){
20662067
var frontendCommandLine =
20672068
frontendPath.asSingle.split(separator: ";").map { String($0) }
20682069
if frontendCommandLine.isEmpty {
20692070
diagnosticsEngine.emit(.error_no_swift_frontend)
20702071
swiftCompilerPrefixArgs = []
2072+
hasFrontendBeenRedirectedForTesting = false
20712073
} else {
2072-
let frontendPath = frontendCommandLine.removeFirst()
2073-
toolchain.overrideToolPath(
2074-
.swiftCompiler, path: try AbsolutePath(validating: frontendPath))
2074+
let frontendPathString = frontendCommandLine.removeFirst()
2075+
let frontendPath = try AbsolutePath(validating: frontendPathString)
2076+
toolchain.overrideToolPath(.swiftCompiler, path: frontendPath)
20752077
swiftCompilerPrefixArgs = frontendCommandLine
2078+
hasFrontendBeenRedirectedForTesting = FileType.isFrontendExtensionForTesting(frontendPath.extension)
20762079
}
20772080
} else {
20782081
swiftCompilerPrefixArgs = []
2079-
}
2080-
var hasFrontendBeenRedirectedForTesting: Bool {
2081-
return !swiftCompilerPrefixArgs.isEmpty
2082+
hasFrontendBeenRedirectedForTesting = false
20822083
}
20832084

20842085
// Find the SDK, if any.

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ extension Driver {
7777
case .swift, .image, .dSYM, .dependencies, .autolink, .swiftDocumentation, .swiftInterface,
7878
.privateSwiftInterface, .swiftSourceInfoFile, .diagnostics, .objcHeader, .swiftDeps,
7979
.remap, .tbd, .moduleTrace, .yamlOptimizationRecord, .bitstreamOptimizationRecord, .pcm,
80-
.pch, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies, nil:
80+
.pch, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies,
81+
.python, nil:
8182
return false
8283
}
8384
}
@@ -355,7 +356,8 @@ extension FileType {
355356
case .swift, .dSYM, .autolink, .dependencies, .swiftDocumentation, .pcm,
356357
.diagnostics, .objcHeader, .image, .swiftDeps, .moduleTrace, .tbd,
357358
.yamlOptimizationRecord, .bitstreamOptimizationRecord, .swiftInterface,
358-
.privateSwiftInterface, .swiftSourceInfoFile, .clangModuleMap, .jsonSwiftArtifacts:
359+
.privateSwiftInterface, .swiftSourceInfoFile, .clangModuleMap, .jsonSwiftArtifacts,
360+
.python:
359361
fatalError("Output type can never be a primary output")
360362
}
361363
}

Sources/SwiftDriver/Utilities/FileType.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,17 @@ 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"
133136
}
134137

135138
extension FileType: CustomStringConvertible {
136139
public var description: String {
137140
switch self {
138141
case .swift, .sil, .sib, .image, .dSYM, .dependencies, .autolink,
139142
.swiftModule, .swiftDocumentation, .swiftInterface, .swiftSourceInfoFile, .assembly,
140-
.remap, .tbd, .pcm, .pch, .clangModuleMap:
143+
.remap, .tbd, .pcm, .pch, .clangModuleMap, .python:
141144
return rawValue
142145
case .object:
143146
return "object"
@@ -211,7 +214,8 @@ extension FileType {
211214
.swiftDocumentation, .pcm, .diagnostics, .objcHeader, .image,
212215
.swiftDeps, .moduleTrace, .tbd, .yamlOptimizationRecord, .bitstreamOptimizationRecord,
213216
.swiftInterface, .privateSwiftInterface, .swiftSourceInfoFile, .jsonDependencies,
214-
.clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies:
217+
.clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies,
218+
.python:
215219
return false
216220
}
217221
}
@@ -302,6 +306,8 @@ extension FileType {
302306
return "bitstream-opt-record"
303307
case .diagnostics:
304308
return "diagnostics"
309+
case .python:
310+
return "python"
305311
}
306312
}
307313
}
@@ -313,7 +319,7 @@ extension FileType {
313319
.objcHeader, .autolink, .importedModules, .tbd, .moduleTrace,
314320
.yamlOptimizationRecord, .swiftInterface, .privateSwiftInterface,
315321
.jsonDependencies, .clangModuleMap, .jsonTargetInfo, .jsonSwiftArtifacts,
316-
.jsonClangDependencies:
322+
.jsonClangDependencies, .python:
317323
return true
318324
case .image, .object, .dSYM, .pch, .sib, .raw_sib, .swiftModule,
319325
.swiftDocumentation, .swiftSourceInfoFile, .llvmBitcode, .diagnostics,
@@ -333,8 +339,13 @@ extension FileType {
333339
.swiftSourceInfoFile, .raw_sil, .raw_sib, .diagnostics, .objcHeader, .swiftDeps, .remap,
334340
.importedModules, .tbd, .moduleTrace, .indexData, .yamlOptimizationRecord,
335341
.bitstreamOptimizationRecord, .pcm, .pch, .jsonDependencies, .clangModuleMap,
336-
.jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies:
342+
.jsonTargetInfo, .jsonSwiftArtifacts, .jsonClangDependencies, .python:
337343
return false
338344
}
339345
}
346+
347+
static func isFrontendExtensionForTesting(_ extension: String?) -> Bool {
348+
python.rawValue == `extension`
349+
}
350+
340351
}

0 commit comments

Comments
 (0)