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 <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Feb 24, 2018 at 00:39 UTC 40dc533f5776aa0fe194176032f7eb38ee5f44b7
1 file changed +20 -16
t/t3030-merge-recursive.sh
+20 -16
@@ -525,20 +525,22 @@ test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '
525 GIT_INDEX_FILE="$PWD/ours-has-rename-index" &&
526 export GIT_INDEX_FILE &&
527 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 + ) &&
537 cat >expected-files <<-EOF &&
538 100644 $o3 0 b/c
539 100644 $o0 0 c
540 100644 $o0 0 d/e
541 100644 $o0 0 e
542 EOF
540 - test_cmp expected-files actual-files &&
541 - test_cmp expected-err actual-err
543 + test_cmp expected-files actual-files
544 '
545
546 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' '
550 GIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&
551 export GIT_INDEX_FILE &&
552 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 + ) &&
562 cat >expected-files <<-EOF &&
563 100644 $o3 0 b/c
564 100644 $o0 0 c
565 100644 $o0 0 d/e
566 100644 $o0 0 e
567 EOF
563 - test_cmp expected-files actual-files &&
564 - test_cmp expected-err actual-err
568 + test_cmp expected-files actual-files
569 '
570
571 test_expect_success 'merge removes empty directories' '