Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Fix: Set `HOME` in PTY tests from `home` crate

Maximilian Roosc279892a864b
diff --git a/Cargo.toml b/Cargo.toml
index 9c5cb613f..c69831273 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -90,6 +90,7 @@ portable-pty = "0.9"
regex = "1.12"
vt100 = "0.16"
fs2 = "0.4"
+home = "0.5.12"
[[bench]]
name = "completion"
diff --git a/tests/common/progressive_output.rs b/tests/common/progressive_output.rs
index 51dd93618..0f9e14fc6 100644
--- a/tests/common/progressive_output.rs
+++ b/tests/common/progressive_output.rs
@@ -495,7 +495,10 @@ fn configure_pty_environment(cmd: &mut CommandBuilder, repo: &TestRepo) {
// Basic environment
cmd.env(
"HOME",
- std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
+ home::home_dir()
+ .expect("HOME directory required")
+ .to_string_lossy()
+ .to_string(),
);
cmd.env(
"PATH",
diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rs
index 355ad496e..e05ce64a1 100644
--- a/tests/integration_tests/approval_pty.rs
+++ b/tests/integration_tests/approval_pty.rs
@@ -49,7 +49,10 @@ fn exec_in_pty_with_input(
cmd.env_clear();
cmd.env(
"HOME",
- std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
+ home::home_dir()
+ .expect("HOME directory required")
+ .to_string_lossy()
+ .to_string(),
);
cmd.env(
"PATH",
diff --git a/tests/integration_tests/list_pty.rs b/tests/integration_tests/list_pty.rs
index 0c2fd9a05..783f3e3e6 100644
--- a/tests/integration_tests/list_pty.rs
+++ b/tests/integration_tests/list_pty.rs
@@ -41,7 +41,10 @@ fn exec_wt_list_in_pty(
cmd.env_clear();
cmd.env(
"HOME",
- std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
+ home::home_dir()
+ .expect("HOME directory required")
+ .to_string_lossy()
+ .to_string(),
);
cmd.env(
"PATH",
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rs
index 62541c91b..4bf38d400 100644
--- a/tests/integration_tests/shell_wrapper.rs
+++ b/tests/integration_tests/shell_wrapper.rs
@@ -318,7 +318,10 @@ fn exec_in_pty_interactive(
// Set minimal required environment for shells to function
cmd.env(
"HOME",
- std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
+ home::home_dir()
+ .expect("HOME directory required")
+ .to_string_lossy()
+ .to_string(),
);
cmd.env(
"PATH",
@@ -2401,7 +2404,10 @@ test = "echo 'Running tests...'"
cmd.env_clear();
cmd.env(
"HOME",
- std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
+ home::home_dir()
+ .expect("HOME directory required")
+ .to_string_lossy()
+ .to_string(),
);
cmd.env(
"PATH",