Skip to content

Commit 30db51a

Browse files
committed
Merge branch 'jk/test-chain-lint'
People often forget to chain the commands in their test together with &&, leaving a failure from an earlier command in the test go unnoticed. The new GIT_TEST_CHAIN_LINT mechanism allows you to catch such a mistake more easily. * jk/test-chain-lint: (36 commits) t9001: drop save_confirm helper t0020: use test_* helpers instead of hand-rolled messages t: simplify loop exit-code status variables t: fix some trivial cases of ignored exit codes in loops t7701: fix ignored exit code inside loop t3305: fix ignored exit code inside loop t0020: fix ignored exit code inside loops perf-lib: fix ignored exit code inside loop t6039: fix broken && chain t9158, t9161: fix broken &&-chain in git-svn tests t9104: fix test for following larger parents t4104: drop hand-rolled error reporting t0005: fix broken &&-chains t7004: fix embedded single-quotes t0050: appease --chain-lint t9001: use test_when_finished t4117: use modern test_* helpers t6034: use modern test_* helpers t1301: use modern test_* helpers t0020: use modern test_* helpers ...
2 parents 55a3b3c + fc99da1 commit 30db51a

File tree

102 files changed

+459
-773
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+459
-773
lines changed

t/README

+10
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ appropriately before running "make".
168168
Using this option with a RAM-based filesystem (such as tmpfs)
169169
can massively speed up the test suite.
170170

171+
--chain-lint::
172+
--no-chain-lint::
173+
If --chain-lint is enabled, the test harness will check each
174+
test to make sure that it properly "&&-chains" all commands (so
175+
that a failure in the middle does not go unnoticed by the final
176+
exit code of the test). This check is performed in addition to
177+
running the tests themselves. You may also enable or disable
178+
this feature by setting the GIT_TEST_CHAIN_LINT environment
179+
variable to "1" or "0", respectively.
180+
171181
You can also set the GIT_TEST_INSTALLED environment variable to
172182
the bindir of an existing git installation to test that installation.
173183
You still need to have built this git sandbox, from which various

t/annotate-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ test_expect_success 'setup -L :regex' '
405405
mv hello.c hello.orig &&
406406
echo "#include <stdio.h>" >hello.c &&
407407
cat hello.orig >>hello.c &&
408-
tr Q "\\t" >>hello.c <<-\EOF
408+
tr Q "\\t" >>hello.c <<-\EOF &&
409409
void mail()
410410
{
411411
Qputs("mail");

t/perf/perf-lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ test_perf_create_repo_from () {
9191
*/objects|*/hooks|*/config)
9292
;;
9393
*)
94-
cp -R "$stuff" . || break
94+
cp -R "$stuff" . || exit 1
9595
;;
9696
esac
9797
done &&

t/t0000-basic.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ test_expect_success 'test --verbose' '
253253
test_expect_success "failing test" false
254254
test_done
255255
EOF
256-
mv test-verbose/out test-verbose/out+
256+
mv test-verbose/out test-verbose/out+ &&
257257
grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out &&
258258
check_sub_test_lib_test test-verbose <<-\EOF
259259
> expecting success: true
@@ -974,7 +974,7 @@ test_expect_success 'writing this tree with --missing-ok' '
974974

975975
################################################################
976976
test_expect_success 'git read-tree followed by write-tree should be idempotent' '
977-
rm -f .git/index
977+
rm -f .git/index &&
978978
git read-tree $tree &&
979979
test -f .git/index &&
980980
newtree=$(git write-tree) &&

t/t0005-signals.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ one
1010
EOF
1111

1212
test_expect_success 'sigchain works' '
13-
test-sigchain >actual
14-
case "$?" in
13+
{ test-sigchain >actual; ret=$?; } &&
14+
case "$ret" in
1515
143) true ;; # POSIX w/ SIGTERM=15
1616
271) true ;; # ksh w/ SIGTERM=15
1717
3) true ;; # Windows
@@ -40,12 +40,12 @@ test_expect_success 'create blob' '
4040
'
4141

4242
test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
43-
OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 )
43+
OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
4444
test "$OUT" -eq 141
4545
'
4646

4747
test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
48-
OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 )
48+
OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
4949
test "$OUT" -eq 141
5050
'
5151

t/t0011-hashmap.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ test_expect_success 'grow / shrink' '
218218
echo size >> in &&
219219
echo 64 51 >> expect &&
220220
echo put key52 value52 >> in &&
221-
echo NULL >> expect
221+
echo NULL >> expect &&
222222
echo size >> in &&
223223
echo 256 52 >> expect &&
224224
for n in $(test_seq 12)

0 commit comments

Comments
 (0)