Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: bound config-show's zsh probe and isolate tests from host env (#3165)
Maximilian Roos3ea7392a65d5
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rsindex 5cb75ca0e..d6e327faf 100644--- a/src/commands/config/show.rs+++ b/src/commands/config/show.rs@@ -250,9 +250,17 @@ fn check_zsh_compinit_missing() -> bool {// The (( ... )) arithmetic returns exit 0 if true (compdef exists), 1 if false// Suppress zsh's "insecure directories" warning from compinit.// See detailed rationale in shell::detect_zsh_compinit().+ //+ // Bound the probe with a timeout that kills the child on expiry — the same+ // hardening detect_zsh_compinit() relies on. An interactive `zsh -ic` whose+ // startup prompts on /dev/tty (compinit's insecure-directories prompt+ // bypasses both the stdin=null default and the stderr suppression above)+ // would otherwise hang `wt config show` indefinitely. On timeout run()+ // returns Err, so the `else` below declines to warn rather than misreport.let Ok(output) = Cmd::new("zsh").args(["--no-globalrcs", "-ic", "(( $+functions[compdef] ))"]).env("ZSH_DISABLE_COMPFIX", "true")+ .timeout(std::time::Duration::from_secs(2)).run()else {return false; // Can't determine, don't warndiff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex b8214050a..4912a3076 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -2410,7 +2410,11 @@ fn test_nushell_install_target_is_a_vendor_autoload_dir(repo: TestRepo, temp_hom// Ask the same `nu` (HOME isolated to temp_home) where it autoloads vendor// files, then confirm worktrunk's wrapper landed in one of those dirs.let listing = std::process::Command::new("nu")- .args(["-c", "$nu.vendor-autoload-dirs | str join (char newline)"])+ .args([+ "--no-config-file",+ "-c",+ "$nu.vendor-autoload-dirs | str join (char newline)",+ ]).env("HOME", &home).env("XDG_CONFIG_HOME", home.join(".config")).output()diff --git a/tests/integration_tests/help.rs b/tests/integration_tests/help.rsindex ffbe777c6..b19bad9a7 100644--- a/tests/integration_tests/help.rs+++ b/tests/integration_tests/help.rs@@ -155,11 +155,12 @@ fn test_help_goes_to_stdout() {}/// When stdout is piped, help must be plain text — no ANSI escapes leaking into-/// `wt --help > file.txt` or `wt --help | less`. Uses the raw binary so-/// `CLICOLOR_FORCE` (set by `wt_command`) doesn't override color detection.+/// `wt --help > file.txt` or `wt --help | less`. Built from `wt_command()` for+/// HOME/config isolation, then clears the `CLICOLOR_FORCE` it sets so color+/// detection sees a non-tty (piped) stdout.#[test]fn test_help_strips_ansi_when_piped() {- let output = std::process::Command::new(env!("CARGO_BIN_EXE_wt"))+ let output = wt_command().arg("--help").env_remove("CLICOLOR_FORCE").env("NO_COLOR", "1")diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rsindex 70d5efb08..23688853b 100644--- a/tests/integration_tests/merge.rs+++ b/tests/integration_tests/merge.rs@@ -2807,9 +2807,13 @@ command = "cat >/dev/null && echo 'feat: combined feature work'"));// The feature branch must still have its multiple commits — squash didn't run.- let log = std::process::Command::new("git")- .args(["-C", feature_wt.to_str().unwrap(), "log", "--oneline"])- .output()+ // Use the repo's isolated git_command (test GIT_CONFIG_GLOBAL, LC_ALL=C)+ // rather than a bare `git` spawn that would inherit the host's gitconfig.+ let log = repo+ .git_command()+ .args(["log", "--oneline"])+ .current_dir(feature_wt)+ .run().expect("git log failed");let log_text = String::from_utf8(log.stdout).unwrap();assert!(diff --git a/tests/integration_tests/nushell_default_config_dir.rs b/tests/integration_tests/nushell_default_config_dir.rsindex 5b89c119a..01b0ae490 100644--- a/tests/integration_tests/nushell_default_config_dir.rs+++ b/tests/integration_tests/nushell_default_config_dir.rs@@ -17,7 +17,7 @@ use std::process::Command;fn run_nu_default_config_dir(configure_env: impl FnOnce(&mut Command)) -> String {let mut cmd = Command::new("nu");- cmd.args(["-c", "echo $nu.default-config-dir"]);+ cmd.args(["--no-config-file", "-c", "echo $nu.default-config-dir"]);configure_env(&mut cmd);let output = cmd.output()diff --git a/tests/integration_tests/statusline.rs b/tests/integration_tests/statusline.rsindex 38ea96851..992c00a39 100644--- a/tests/integration_tests/statusline.rs+++ b/tests/integration_tests/statusline.rs@@ -24,6 +24,12 @@ fn run_statusline_from_dir(// Apply repo's git environmentrepo.configure_wt_cmd(&mut cmd);+ // Pin the timezone so any wall-clock segment (the claude-code statusline+ // renders `chrono::Local`) is deterministic across machines — not only in+ // the `run_statusline_with_locale` helper. `LC_ALL=C` is already pinned+ // globally by the test harness.+ cmd.env("TZ", "UTC");+if stdin_json.is_some() {cmd.stdin(Stdio::piped());}