On 23/04/18 09:34AM, Junio C Hamano wrote: > Jacob Abel <jacobabel@xxxxxxxxxx> writes: > > > [...] > > Here is how it fails and test_must_be_empty complains that the > "actual" file is not empty, if you run the script with "-x -i" after > applying the patch in the message you are responding to on top of > this step. > > [...] > > Observe what test_must_be_empty does in the last part of the > transcript above. If you run it without "-i", then the trace will > show "cat actual" twice (one from test_must_be_empty above, then a > redundant one from the test_when_finished). > > Another reason why we shouldn't add this to test_when_finished is > because it would not help those who run the tests with "-i" option. > The test_cleanup handlers are meant to be "clean-up" routines, and > they are not run when the user uses "-i", intending to go into the > test directory after seeing the test fail and inspect what is left > there. Ah ok I understand what you mean now. Would the following work? Since all we care about in `git worktree add` is `stderr`, can't we just duplicate `stderr` to `stdout` while redirecting stderr to `actual` so that in the event the git command fails, it's still displayed in the output of `sh t2400-*.sh -x`? diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 82091cbb1f..a8f734b1c3 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -327,8 +327,7 @@ test_expect_success 'add -B' ' test_expect_success 'add --quiet' ' test_when_finished "git worktree remove -f -f another-worktree" && - test_when_finished "cat actual" && - git worktree add --quiet another-worktree main 2>actual && + git worktree add --quiet another-worktree main 2>actual 2>&1 && test_must_be_empty actual '