Skip to content

A fix for incorrectly overriding environment variables rdar://118814900 #7144

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 1 commit into from
Dec 8, 2023
Merged
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
A fix for overriding environment variables rdar://118814900
  • Loading branch information
pusukuri committed Dec 7, 2023
commit 6e0edf89f4de3338fd72b65eda477c6c476c0845
14 changes: 8 additions & 6 deletions Sources/SPMTestSupport/SwiftPMProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ extension SwiftPM {
env: [String: String]? = nil
) throws -> ProcessResult {
var environment = ProcessInfo.processInfo.environment
for (key, value) in env ?? [:] {
environment[key] = value
}
#if !os(Windows)
environment["SDKROOT"] = nil
#endif

#if Xcode
// Unset these variables which causes issues when running tests via Xcode.
environment["XCTestConfigurationFilePath"] = nil
Expand All @@ -114,13 +115,14 @@ extension SwiftPM {
// FIXME: We use this private environment variable hack to be able to
// create special conditions in swift-build for swiftpm tests.
environment["SWIFTPM_TESTS_MODULECACHE"] = xctestBinaryPath.parentDirectory.pathString
#if !os(Windows)
environment["SDKROOT"] = nil
#endif

// Unset the internal env variable that allows skipping certain tests.
environment["_SWIFTPM_SKIP_TESTS_LIST"] = nil

for (key, value) in env ?? [:] {
environment[key] = value
}

var completeArgs = [xctestBinaryPath.pathString]
if let packagePath = packagePath {
completeArgs += ["--package-path", packagePath.pathString]
Expand Down