huskies: merge 1238 bug worktree tests fail on macOS: tests clobber global HOME

This commit is contained in:
Huskies Agent
2026-07-21 12:10:20 +00:00
parent 22710571df
commit 8a32c1ffd8
20 changed files with 488 additions and 248 deletions
+22
View File
@@ -0,0 +1,22 @@
//! Shared test helper for driving `git` as a subprocess in unit tests.
//!
//! `Command::output()` resolves to `Ok` even when the spawned process exits
//! non-zero — a bare `.expect(...)`/`.unwrap()` on that `Output` only
//! checks that the process could be spawned, not that git itself
//! succeeded. A failed `git commit` (e.g. missing `user.name`/`user.email`
//! identity) then silently leaves the repo without the commit the rest of
//! the test assumes exists, surfacing later as a confusing, unrelated
//! assertion failure instead of the real git error.
use std::io;
use std::process::Output;
/// Unwrap a `git` subprocess result, panicking with `context` and git's
/// stderr if the process failed to spawn or exited non-zero.
pub(crate) fn git_ok(output: io::Result<Output>, context: &str) -> Output {
let output = output.unwrap_or_else(|e| panic!("{context}: failed to run git: {e}"));
if !output.status.success() {
panic!("{context}: {}", String::from_utf8_lossy(&output.stderr));
}
output
}