Skip to content

Commit 54eb4f1

Browse files
committed
test: run git non-interactively in test helpers
After resolving conflicts, `git rebase --continue` opens an editor by default on the merge backend (git >= 2.26) to confirm the commit message. CI runners have no editor (no tty, EDITOR/GIT_EDITOR unset), so it fails with "Terminal is dumb, but EDITOR unset", breaking the two tests that assert `git rebase --continue` succeeds: rebase_continue_corrupted_state_file and rebase_continue_skip_progress_reporting. Set GIT_EDITOR/GIT_SEQUENCE_EDITOR=true in the command helpers so git reuses the existing commit message non-interactively, mirroring git's own test harness (GIT_EDITOR=:). These tests pass on macOS (local editor configured) but failed on the ubuntu CI runners.
1 parent 0eae6e0 commit 54eb4f1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/common/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ where
226226
assert_cmd::Command::cargo_bin(env!("CARGO_PKG_NAME"))
227227
.expect("Failed to get git-chain")
228228
.current_dir(current_dir_buf)
229+
// Ensure any `git` subprocess spawned by git-chain runs non-interactively.
230+
// Without this, `git rebase --continue` (merge backend, git >= 2.26) tries
231+
// to open an editor and fails on CI with "Terminal is dumb, but EDITOR unset".
232+
.env("GIT_EDITOR", "true")
233+
.env("GIT_SEQUENCE_EDITOR", "true")
229234
.args(arguments)
230235
.output()
231236
.expect("Failed to run git-chain")
@@ -252,6 +257,10 @@ where
252257
assert_cmd::Command::cargo_bin(env!("CARGO_PKG_NAME")).expect("Failed to get git-chain");
253258

254259
cmd.current_dir(current_dir_buf)
260+
// Non-interactive git defaults (see run_test_bin); caller-supplied
261+
// env_vars are applied afterwards and therefore take precedence.
262+
.env("GIT_EDITOR", "true")
263+
.env("GIT_SEQUENCE_EDITOR", "true")
255264
.args(arguments)
256265
.envs(env_vars);
257266

@@ -313,6 +322,12 @@ where
313322

314323
let output = assert_cmd::Command::from_std(Command::new("git"))
315324
.current_dir(current_dir_buf)
325+
// Run git non-interactively so commands like `git rebase --continue`
326+
// (merge backend, git >= 2.26) reuse the existing commit message instead
327+
// of launching an editor, which fails on CI ("Terminal is dumb, but
328+
// EDITOR unset"). Mirrors git's own test harness (GIT_EDITOR=:).
329+
.env("GIT_EDITOR", "true")
330+
.env("GIT_SEQUENCE_EDITOR", "true")
316331
.args(arguments)
317332
.output()
318333
.expect("Failed to run git");

0 commit comments

Comments
 (0)