Skip to content

Commit 4960048

Browse files
committed
Clean up and pass the environment to the swift version invocation
1 parent c45a29a commit 4960048

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

Tests/SwiftlyTests/E2ETests.swift

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,19 @@ final class E2ETests: SwiftlyTests {
8686

8787
let shell = try await Swiftly.currentPlatform.getShell()
8888

89-
// TODO: remove this
90-
print("CHECKING /root/.profile")
91-
try Swiftly.currentPlatform.runProgram("cat", "/root/.profile")
92-
if FileManager.default.fileExists(atPath: "/root/.bash_profile") {
93-
print("FILE EXISTS! /root/.bash_profile")
94-
}
95-
if FileManager.default.fileExists(atPath: "/root/.bash_login") {
96-
print("FILE EXISTS! /root/.bash_login")
89+
var env = ProcessInfo.processInfo.environment
90+
91+
// Setting this environment helps to ensure that the profile gets sourced with bash, even if it is not in an interactive shell
92+
if shell == "/bin/bash" {
93+
env["BASH_ENV"] = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".profile").path
9794
}
98-
try Swiftly.currentPlatform.runProgram(shell, "-v", "-l", "-c", "shopt")
9995

100-
var env = ProcessInfo.processInfo.environment
101-
env["BASH_ENV"] = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".profile").path
102-
try Swiftly.currentPlatform.runProgram(shell, "-v", "-l", "-c", "swiftly install --assume-yes latest --post-install-file=./post-install.sh", env: env)
96+
try Swiftly.currentPlatform.runProgram(shell, "-l", "-c", "swiftly install --assume-yes latest --post-install-file=./post-install.sh", env: env)
10397

104-
// TODO: check if the user is root already before runing post install
10598
if FileManager.default.fileExists(atPath: "./post-install.sh") {
106-
#if os(Linux)
107-
if !FileManager.default.fileExists(atPath: "/etc/timezone") {
108-
// Prevent tzdata package installation from trying to prompt for the time zone
109-
try? Swiftly.currentPlatform.runProgram(shell, "echo 'Etc/UTC' > /etc/timezone")
110-
}
111-
#endif
11299
try Swiftly.currentPlatform.runProgram(shell, "./post-install.sh")
113100
}
114101

115-
try Swiftly.currentPlatform.runProgram(shell, "-v", "-l", "-c", "swift --version", quiet: false)
102+
try Swiftly.currentPlatform.runProgram(shell, "-l", "-c", "swift --version", quiet: false, env: env)
116103
}
117104
}

0 commit comments

Comments
 (0)