Skip to content

[Integrated Tests] Invoke lit.py using python3 #570

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 3 commits into from
Mar 29, 2021
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
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,8 @@ extension Driver {
}

var appliesToFetchingTargetInfo: Bool {
return overridePath?.basename != "Python"
return overridePath?.basename != "Python" &&
overridePath?.basename != "python3"
}
func setUpForTargetInfo(_ toolchain: Toolchain) {
if !appliesToFetchingTargetInfo {
Expand Down
9 changes: 7 additions & 2 deletions Tests/SwiftDriverTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ private func bundleRoot() -> AbsolutePath {

private let packageDirectory = AbsolutePath(#file).parentDirectory.parentDirectory.parentDirectory

// The "default" here means lit.py will be invoked as an executable, while otherwise let's use
// python 3 explicitly.
private let pythonExec = ProcessEnv.vars.keys.contains("SWIFT_DRIVER_INTEGRATION_TESTS_USE_PYTHON_DEFAULT") ? "" : "python3"

func makeDriverSymlinks(
in tempDir: AbsolutePath,
with swiftBuildDir: AbsolutePath? = nil
Expand Down Expand Up @@ -199,6 +203,7 @@ final class IntegrationTests: IntegrationTestCase {
"--param", "swift_driver",
testDir.pathString
]
let commandArgs = pythonExec.isEmpty ? args : [pythonExec] + args

let extraEnv = [
"SWIFT": swift.pathString,
Expand All @@ -207,10 +212,10 @@ final class IntegrationTests: IntegrationTestCase {
"LC_ALL": "en_US.UTF-8"
]

printCommand(args: args, extraEnv: extraEnv)
printCommand(args: commandArgs, extraEnv: extraEnv)

let process = TSCBasic.Process(
arguments: args,
arguments: commandArgs,
environment: ProcessEnv.vars.merging(extraEnv) { $1 },
outputRedirection: .none
)
Expand Down