Skip to content

Commit 59c2220

Browse files
committed
status test: add missing && to <<EOF blocks
When a test forgets to include && after each command, it is possible for an early command to succeed but the test to fail, which can hide bugs. Checked using the following patch to the test harness: --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -425,7 +425,17 @@ test_eval_ () { eval </dev/null >&3 2>&4 "$*" } +check_command_chaining_ () { + eval >&3 2>&4 "(exit 189) && $*" + eval_chain_ret=$? + if test "$eval_chain_ret" != 189 + then + error 'bug in test script: missing "&&" in test commands' + fi +} + test_run_ () { + check_command_chaining_ "$1" test_cleanup=: expecting_failure=$2 setup_malloc_check Signed-off-by: Jonathan Nieder <[email protected]>
1 parent 1e15535 commit 59c2220

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

t/t7512-status-help.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,15 +669,15 @@ EOF
669669
test_expect_success 'status showing detached at and from a tag' '
670670
test_commit atag tagging &&
671671
git checkout atag &&
672-
cat >expected <<\EOF
672+
cat >expected <<\EOF &&
673673
HEAD detached at atag
674674
nothing to commit (use -u to show untracked files)
675675
EOF
676676
git status --untracked-files=no >actual &&
677677
test_i18ncmp expected actual &&
678678
679679
git reset --hard HEAD^ &&
680-
cat >expected <<\EOF
680+
cat >expected <<\EOF &&
681681
HEAD detached from atag
682682
nothing to commit (use -u to show untracked files)
683683
EOF
@@ -695,7 +695,7 @@ test_expect_success 'status while reverting commit (conflicts)' '
695695
test_commit new to-revert.txt &&
696696
TO_REVERT=$(git rev-parse --short HEAD^) &&
697697
test_must_fail git revert $TO_REVERT &&
698-
cat >expected <<EOF
698+
cat >expected <<EOF &&
699699
On branch master
700700
You are currently reverting commit $TO_REVERT.
701701
(fix conflicts and run "git revert --continue")
@@ -716,7 +716,7 @@ EOF
716716
test_expect_success 'status while reverting commit (conflicts resolved)' '
717717
echo reverted >to-revert.txt &&
718718
git add to-revert.txt &&
719-
cat >expected <<EOF
719+
cat >expected <<EOF &&
720720
On branch master
721721
You are currently reverting commit $TO_REVERT.
722722
(all conflicts fixed: run "git revert --continue")
@@ -735,7 +735,7 @@ EOF
735735

736736
test_expect_success 'status after reverting commit' '
737737
git revert --continue &&
738-
cat >expected <<\EOF
738+
cat >expected <<\EOF &&
739739
On branch master
740740
nothing to commit (use -u to show untracked files)
741741
EOF

0 commit comments

Comments
 (0)