Skip to content

Commit 40dc533

Browse files
szedergitster
authored andcommitted
t3030-merge-recursive: don't check the stderr of a subshell
The two test checking 'git mmerge-recursive' in an empty worktree in 't3030-merge-recursive.sh' fail when the test script is run with '-x' tracing (and using a shell other than a Bash version supporting BASH_XTRACEFD). The reason for those failures is that the tests check the emptiness of a subshell's stderr, which includes the trace of commands executed in that subshell as well, throwing off the emptiness check. Note that both subshells execute four git commands each, meaning that checking the emptiness of the whole subshell implicitly ensures that not only 'git merge-recursive' but none of the other three commands outputs anything to their stderr. Note also that if one of those commands were to output anything on its stderr, then the current combined check would not tell us which one of those four commands the unexpected output came from. Save the stderr of those four commands only instead of the whole subshell, so it remains free from tracing output, and save and check them individually, so they will show us from which command the unexpected output came from. After this change t3030 passes with '-x', even when running with /bin/sh. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3a4456 commit 40dc533

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

t/t3030-merge-recursive.sh

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -525,20 +525,22 @@ test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '
525525
GIT_INDEX_FILE="$PWD/ours-has-rename-index" &&
526526
export GIT_INDEX_FILE &&
527527
mkdir "$GIT_WORK_TREE" &&
528-
git read-tree -i -m $c7 &&
529-
git update-index --ignore-missing --refresh &&
530-
git merge-recursive $c0 -- $c7 $c3 &&
531-
git ls-files -s >actual-files
532-
) 2>actual-err &&
533-
>expected-err &&
528+
git read-tree -i -m $c7 2>actual-err &&
529+
test_must_be_empty actual-err &&
530+
git update-index --ignore-missing --refresh 2>actual-err &&
531+
test_must_be_empty actual-err &&
532+
git merge-recursive $c0 -- $c7 $c3 2>actual-err &&
533+
test_must_be_empty actual-err &&
534+
git ls-files -s >actual-files 2>actual-err &&
535+
test_must_be_empty actual-err
536+
) &&
534537
cat >expected-files <<-EOF &&
535538
100644 $o3 0 b/c
536539
100644 $o0 0 c
537540
100644 $o0 0 d/e
538541
100644 $o0 0 e
539542
EOF
540-
test_cmp expected-files actual-files &&
541-
test_cmp expected-err actual-err
543+
test_cmp expected-files actual-files
542544
'
543545

544546
test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' '
@@ -548,20 +550,22 @@ test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' '
548550
GIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&
549551
export GIT_INDEX_FILE &&
550552
mkdir "$GIT_WORK_TREE" &&
551-
git read-tree -i -m $c3 &&
552-
git update-index --ignore-missing --refresh &&
553-
git merge-recursive $c0 -- $c3 $c7 &&
554-
git ls-files -s >actual-files
555-
) 2>actual-err &&
556-
>expected-err &&
553+
git read-tree -i -m $c3 2>actual-err &&
554+
test_must_be_empty actual-err &&
555+
git update-index --ignore-missing --refresh 2>actual-err &&
556+
test_must_be_empty actual-err &&
557+
git merge-recursive $c0 -- $c3 $c7 2>actual-err &&
558+
test_must_be_empty actual-err &&
559+
git ls-files -s >actual-files 2>actual-err &&
560+
test_must_be_empty actual-err
561+
) &&
557562
cat >expected-files <<-EOF &&
558563
100644 $o3 0 b/c
559564
100644 $o0 0 c
560565
100644 $o0 0 d/e
561566
100644 $o0 0 e
562567
EOF
563-
test_cmp expected-files actual-files &&
564-
test_cmp expected-err actual-err
568+
test_cmp expected-files actual-files
565569
'
566570

567571
test_expect_success 'merge removes empty directories' '

0 commit comments

Comments
 (0)