Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor: Isolate test environment from user setup
Maximilian Roos634183c2139a
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex df3d3f8b1..514355fe5 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -232,6 +232,24 @@ fn exec_in_pty(// Spawn the shell inside the PTYlet mut cmd = CommandBuilder::new(shell);+ // Clear inherited environment for test isolation+ // This prevents user environment (ZELLIJ, TMUX, custom aliases, etc.) from+ // affecting test behavior or causing side effects (e.g., renaming Zellij tabs)+ cmd.env_clear();++ // Set minimal required environment for shells to function+ // HOME and PATH are preserved for rustup/cargo and finding git/commands+ cmd.env(+ "HOME",+ std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),+ );+ cmd.env(+ "PATH",+ std::env::var("PATH").unwrap_or_else(|_| "/usr/bin:/bin".to_string()),+ );+ cmd.env("USER", "testuser");+ cmd.env("SHELL", shell);+// For zsh, isolate from user rc files to prevent TTY access issues// User startup files (~/.zshenv, ~/.zshrc) can touch /dev/tty (e.g., stty, zle,// compinit, GPG_TTY=$(tty)) which causes SIGTTIN/TTOU/TSTP signals when the@@ -255,7 +273,7 @@ fn exec_in_pty(cmd.arg(script);cmd.cwd(working_dir);- // Add environment variables+ // Add test-specific environment variablesfor (key, value) in env_vars {cmd.env(key, value);}diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snapindex c78f6e87f..6c5cf2a31 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap@@ -3,7 +3,7 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()---π [36mRunning pre-merge: [1mcheck1[0m:[0m-[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.worktree-failure/tests/fixtures/mixed-output.sh[0m check1 3[0m+[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.zellij/tests/fixtures/mixed-output.sh[0m check1 3[0m[check1] stdout line 1[check1] stderr line 1@@ -15,7 +15,7 @@ expression: output.normalized()[check1] stderr completeπ [36mRunning pre-merge: [1mcheck2[0m:[0m-[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.worktree-failure/tests/fixtures/mixed-output.sh[0m check2 3[0m+[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.zellij/tests/fixtures/mixed-output.sh[0m check2 3[0m[check2] stdout line 1[check2] stderr line 1@@ -26,9 +26,9 @@ expression: output.normalized()[check2] stdout complete[check2] stderr complete-π [36mMerging 1 commit to [1m[36mmain[0m @ [2m[36me28e0ba[0m[0m (no commit/squash/rebase needed)+π [36mMerging 1 commit to [1m[36mmain[0m @ [2m[36ma8b5caa[0m[0m (no commit/squash/rebase needed)-[40m [0m * [33me28e0ba[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add feature+[40m [0m * [33ma8b5caa[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add feature[40m [0m feature.txt | 1 [32m+[m[40m [0m 1 file changed, 1 insertion(+)diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snapindex fff418f41..ce551f713 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap@@ -19,16 +19,16 @@ expression: output.normalized()[check2] stdout complete[check2] stderr completeπ [36mRunning pre-merge: [1mcheck1[0m:[0m-[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.worktree-failure/tests/fixtures/mixed-output.sh[0m check1 3[0m+[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.zellij/tests/fixtures/mixed-output.sh[0m check1 3[0mπ [36mRunning pre-merge: [1mcheck2[0m:[0m-[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.worktree-failure/tests/fixtures/mixed-output.sh[0m check2 3[0m+[40m [0m [1m[34m/Users/maximilian/workspace/worktrunk.zellij/tests/fixtures/mixed-output.sh[0m check2 3[0m-π [36mMerging 1 commit to [1m[36mmain[0m @ [2m[36me28e0ba[0m[0m (no commit/squash/rebase needed)+π [36mMerging 1 commit to [1m[36mmain[0m @ [2m[36ma8b5caa[0m[0m (no commit/squash/rebase needed)-[40m [0m * [33me28e0ba[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add feature+[40m [0m * [33ma8b5caa[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add feature[40m [0m feature.txt | 1 [32m+[m[40m [0m 1 file changed, 1 insertion(+)