Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
test(shell): isolate fish startup configuration in PTY fixtures (#4353)
Maximilian Roos9669d4a7bbdd
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex 353a897a8..d64f053a3 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -444,8 +444,12 @@ fn exec_in_pty_shell(cmd.arg("-c");cmd.arg(script);}+ "fish" => {+ cmd.arg("--no-config");+ cmd.arg("-c");+ cmd.arg(script);+ }_ => {- // fish and other shellscmd.arg("-c");cmd.arg(script);}@@ -1782,6 +1786,28 @@ approved-commands = ["echo 'fish background task'"]env::var("PATH").unwrap_or_default());+ // Fish startup configuration can prepend PATH and displace the cargo+ // stub. Shell tests must bypass it, just as bash bypasses ~/.bashrc.+ let startup_bin = repo.home_path().join("startup-bin");+ fs::create_dir_all(&startup_bin).unwrap();+ let startup_cargo = startup_bin.join("cargo");+ fs::write(+ &startup_cargo,+ "#!/bin/sh\necho 'unexpected startup cargo' >&2\nexit 23\n",+ )+ .unwrap();+ fs::set_permissions(&startup_cargo, fs::Permissions::from_mode(0o755)).unwrap();+ let fish_config = repo.home_path().join(".config/fish");+ fs::create_dir_all(&fish_config).unwrap();+ fs::write(+ fish_config.join("config.fish"),+ format!(+ "fish_add_path {}\n",+ shell_quote(&startup_bin.to_string_lossy())+ ),+ )+ .unwrap();+// Get the worktrunk source directory (where this test is running from)// This is the directory that contains Cargo.toml with the workspacelet worktrunk_source = canonicalize(&env::current_dir().unwrap()).unwrap();@@ -1803,7 +1829,15 @@ approved-commands = ["echo 'fish background task'"]let config_path = repo.test_config_path().to_string_lossy().to_string();let approvals_path = repo.test_approvals_path().to_string_lossy().to_string();+ let fixture_home = repo.home_path().to_string_lossy().to_string();+ let xdg_config = repo+ .home_path()+ .join(".config")+ .to_string_lossy()+ .to_string();let env_vars: Vec<(&str, &str)> = vec![+ ("HOME", &fixture_home),+ ("XDG_CONFIG_HOME", &xdg_config),("PATH", &stub_path),("CLICOLOR_FORCE", "1"),("WORKTRUNK_CONFIG_PATH", &config_path),