Skip to content

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

test: isolate the two raw git spawns that read the developer's gitconfig (#3863)

Worktrunk Botad8f137f688e
diff --git a/tests/helpers/wt-perf/tests/cli.rs b/tests/helpers/wt-perf/tests/cli.rs
index 35621e818..a74afe903 100644
--- a/tests/helpers/wt-perf/tests/cli.rs
+++ b/tests/helpers/wt-perf/tests/cli.rs
@@ -7,6 +7,8 @@
use std::io::Write;
use std::process::{Command, Output, Stdio};
+use worktrunk::testing::configure_git_cmd;
+
fn wt_perf_bin() -> &'static str {
env!("CARGO_BIN_EXE_wt-perf")
}
@@ -136,7 +138,12 @@ fn setup_layers_prune_state_onto_a_canonical_base() {
String::from_utf8_lossy(&output.stderr)
);
- let branches = Command::new("git")
+ // Fixture inspection is still a `git` the suite runs, so it gets the same
+ // isolation as every other one — the crate's own `git_command()` helper is
+ // private to the lib, so apply the floor directly here.
+ let mut git = Command::new("git");
+ configure_git_cmd(&mut git);
+ let branches = git
.args([
"-C",
repo.to_str().unwrap(),
diff --git a/tests/integration_tests/security.rs b/tests/integration_tests/security.rs
index fdab61e9d..35ad8256c 100644
--- a/tests/integration_tests/security.rs
+++ b/tests/integration_tests/security.rs
@@ -370,7 +370,15 @@ fn test_execute_flag_with_directive_like_branch_name(repo: TestRepo) {
fn test_git_rejects_ansi_escape_in_branch_names(repo: TestRepo) {
let shell_cmd = r#"git branch $'feature-\x1b[31mRED\x1b[0m-test'"#;
- let output = Command::new("bash")
+ // The `git` this bash child spawns inherits its environment, so the
+ // isolation goes on the shell (as it does for the `sh` child above).
+ // `LC_ALL`/`LANG=C` from `git_test_env` is what the stderr assertion below
+ // rests on — git ships translated messages, so on a contributor's machine
+ // with a non-English locale the check for "not a valid branch name" reads a
+ // German or French rendering of it and fails.
+ let mut cmd = Command::new("bash");
+ repo.configure_git_cmd(&mut cmd);
+ let output = cmd
.args(["-c", shell_cmd])
.current_dir(repo.root_path())
.output()