Skip to content

Commit

Permalink
status test: add missing && to <<EOF blocks
Browse files Browse the repository at this point in the history
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 <jrnieder@gmail.com>
  • Loading branch information
jrn committed Oct 11, 2013
1 parent 1e15535 commit 59c2220
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions t/t7512-status-help.sh
Expand Up @@ -669,15 +669,15 @@ EOF
test_expect_success 'status showing detached at and from a tag' '
test_commit atag tagging &&
git checkout atag &&
cat >expected <<\EOF
cat >expected <<\EOF &&
HEAD detached at atag
nothing to commit (use -u to show untracked files)
EOF
git status --untracked-files=no >actual &&
test_i18ncmp expected actual &&
git reset --hard HEAD^ &&
cat >expected <<\EOF
cat >expected <<\EOF &&
HEAD detached from atag
nothing to commit (use -u to show untracked files)
EOF
Expand All @@ -695,7 +695,7 @@ test_expect_success 'status while reverting commit (conflicts)' '
test_commit new to-revert.txt &&
TO_REVERT=$(git rev-parse --short HEAD^) &&
test_must_fail git revert $TO_REVERT &&
cat >expected <<EOF
cat >expected <<EOF &&
On branch master
You are currently reverting commit $TO_REVERT.
(fix conflicts and run "git revert --continue")
Expand All @@ -716,7 +716,7 @@ EOF
test_expect_success 'status while reverting commit (conflicts resolved)' '
echo reverted >to-revert.txt &&
git add to-revert.txt &&
cat >expected <<EOF
cat >expected <<EOF &&
On branch master
You are currently reverting commit $TO_REVERT.
(all conflicts fixed: run "git revert --continue")
Expand All @@ -735,7 +735,7 @@ EOF

test_expect_success 'status after reverting commit' '
git revert --continue &&
cat >expected <<\EOF
cat >expected <<\EOF &&
On branch master
nothing to commit (use -u to show untracked files)
EOF
Expand Down

0 comments on commit 59c2220

Please sign in to comment.