Skip to content

Commit

Permalink
Merge branch 'jk/test-chain-lint'
Browse files Browse the repository at this point in the history
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
  ...
  • Loading branch information
Junio C Hamano committed Mar 26, 2015
2 parents 55a3b3c + fc99da1 commit 30db51a
Show file tree
Hide file tree
Showing 102 changed files with 459 additions and 773 deletions.
10 changes: 10 additions & 0 deletions t/README
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ appropriately before running "make".
Using this option with a RAM-based filesystem (such as tmpfs)
can massively speed up the test suite.

--chain-lint::
--no-chain-lint::
If --chain-lint is enabled, the test harness will check each
test to make sure that it properly "&&-chains" all commands (so
that a failure in the middle does not go unnoticed by the final
exit code of the test). This check is performed in addition to
running the tests themselves. You may also enable or disable
this feature by setting the GIT_TEST_CHAIN_LINT environment
variable to "1" or "0", respectively.

You can also set the GIT_TEST_INSTALLED environment variable to
the bindir of an existing git installation to test that installation.
You still need to have built this git sandbox, from which various
Expand Down
2 changes: 1 addition & 1 deletion t/annotate-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ test_expect_success 'setup -L :regex' '
mv hello.c hello.orig &&
echo "#include <stdio.h>" >hello.c &&
cat hello.orig >>hello.c &&
tr Q "\\t" >>hello.c <<-\EOF
tr Q "\\t" >>hello.c <<-\EOF &&
void mail()
{
Qputs("mail");
Expand Down
2 changes: 1 addition & 1 deletion t/perf/perf-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test_perf_create_repo_from () {
*/objects|*/hooks|*/config)
;;
*)
cp -R "$stuff" . || break
cp -R "$stuff" . || exit 1
;;
esac
done &&
Expand Down
4 changes: 2 additions & 2 deletions t/t0000-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ test_expect_success 'test --verbose' '
test_expect_success "failing test" false
test_done
EOF
mv test-verbose/out test-verbose/out+
mv test-verbose/out test-verbose/out+ &&
grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out &&
check_sub_test_lib_test test-verbose <<-\EOF
> expecting success: true
Expand Down Expand Up @@ -974,7 +974,7 @@ test_expect_success 'writing this tree with --missing-ok' '

################################################################
test_expect_success 'git read-tree followed by write-tree should be idempotent' '
rm -f .git/index
rm -f .git/index &&
git read-tree $tree &&
test -f .git/index &&
newtree=$(git write-tree) &&
Expand Down
8 changes: 4 additions & 4 deletions t/t0005-signals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ one
EOF

test_expect_success 'sigchain works' '
test-sigchain >actual
case "$?" in
{ test-sigchain >actual; ret=$?; } &&
case "$ret" in
143) true ;; # POSIX w/ SIGTERM=15
271) true ;; # ksh w/ SIGTERM=15
3) true ;; # Windows
Expand Down Expand Up @@ -40,12 +40,12 @@ test_expect_success 'create blob' '
'

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

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

Expand Down
2 changes: 1 addition & 1 deletion t/t0011-hashmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ test_expect_success 'grow / shrink' '
echo size >> in &&
echo 64 51 >> expect &&
echo put key52 value52 >> in &&
echo NULL >> expect
echo NULL >> expect &&
echo size >> in &&
echo 256 52 >> expect &&
for n in $(test_seq 12)
Expand Down
Loading

0 comments on commit 30db51a

Please sign in to comment.