Fix env contamination in Process-based UI test app launch
The test runner's environment contains XCTest variables (DYLD_INSERT_LIBRARIES, XCInjectBundle, etc.) that cause the app to hang when inherited by a Process-launched binary. Pass only system essentials + our CMUX_UI_TEST_* vars, matching how the smoke test launches the app with a clean environment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
88751b2d12
commit
e4ef74c8b2
1 changed files with 13 additions and 2 deletions
|
|
@ -245,11 +245,22 @@ final class DisplayResolutionRegressionUITests: XCTestCase {
|
|||
// Running the binary directly works because it doesn't need WindowServer activation.
|
||||
private func launchAppProcess(targetDisplayID: String) throws {
|
||||
let binaryPath = try resolveAppBinaryPath()
|
||||
let env = launchEnvironment(targetDisplayID: targetDisplayID)
|
||||
let appEnv = launchEnvironment(targetDisplayID: targetDisplayID)
|
||||
|
||||
// Build a clean environment with only system essentials + our test vars.
|
||||
// Do NOT pass the test runner's full environment — it contains XCTest
|
||||
// variables (DYLD_INSERT_LIBRARIES, XCInjectBundle, etc.) that cause the
|
||||
// app to hang when launched via Process.
|
||||
let runnerEnv = ProcessInfo.processInfo.environment
|
||||
var cleanEnv = appEnv
|
||||
for key in ["HOME", "PATH", "TMPDIR", "USER", "SHELL", "LANG",
|
||||
"TERM", "LOGNAME", "DISPLAY", "__CF_USER_TEXT_ENCODING"] {
|
||||
if let val = runnerEnv[key] { cleanEnv[key] = val }
|
||||
}
|
||||
|
||||
let proc = Process()
|
||||
proc.executableURL = URL(fileURLWithPath: binaryPath)
|
||||
proc.environment = ProcessInfo.processInfo.environment.merging(env) { _, new in new }
|
||||
proc.environment = cleanEnv
|
||||
|
||||
let logPath = "/tmp/cmux-ui-test-app-\(launchTag).log"
|
||||
FileManager.default.createFile(atPath: logPath, contents: nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue