t: use verbose instead of hand-rolled errors

Many tests that predate the "verbose" helper function use a
pattern like:

  test ... || {
	  echo ...
	  false
  }

to give more verbose output. Using the helper, we can do
this with a single line, and avoid a || which interacts
badly with &&-chaining (besides fooling --chain-lint, we hit
the error block no matter which command in the chain failed,
so we may often show useless results).

In most cases, the messages printed by "verbose" are equally
good (in some cases better; t6006 accidentally redirects the
message to a file!). The exception is t7001, whose output
suffers slightly. However, it's still enough to show the
user which part failed, given that we will have just printed
the test script to stderr.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2015-03-20 06:09:00 -04:00 committed by Junio C Hamano
parent 5ca812a19c
commit a167ece0c8
5 changed files with 10 additions and 45 deletions

View File

@ -20,10 +20,7 @@ test_expect_success setup '
test_expect_success 'detect rewrite' '
actual=$(git diff-files -B --summary test) &&
expr "$actual" : " rewrite test ([0-9]*%)$" || {
echo "Eh? <<$actual>>"
false
}
verbose expr "$actual" : " rewrite test ([0-9]*%)$"
'

View File

@ -113,11 +113,7 @@ test_expect_success 'diff-filter=M' '
actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
expect=$(echo second) &&
test "$actual" = "$expect" || {
echo Oops
echo "Actual: $actual"
false
}
verbose test "$actual" = "$expect"
'
@ -125,11 +121,7 @@ test_expect_success 'diff-filter=D' '
actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
expect=$(echo sixth ; echo third) &&
test "$actual" = "$expect" || {
echo Oops
echo "Actual: $actual"
false
}
verbose test "$actual" = "$expect"
'
@ -137,11 +129,7 @@ test_expect_success 'diff-filter=R' '
actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
expect=$(echo third) &&
test "$actual" = "$expect" || {
echo Oops
echo "Actual: $actual"
false
}
verbose test "$actual" = "$expect"
'
@ -149,11 +137,7 @@ test_expect_success 'diff-filter=C' '
actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
expect=$(echo fourth) &&
test "$actual" = "$expect" || {
echo Oops
echo "Actual: $actual"
false
}
verbose test "$actual" = "$expect"
'
@ -161,11 +145,7 @@ test_expect_success 'git log --follow' '
actual=$(git log --follow --pretty="format:%s" ichi) &&
expect=$(echo third ; echo second ; echo initial) &&
test "$actual" = "$expect" || {
echo Oops
echo "Actual: $actual"
false
}
verbose test "$actual" = "$expect"
'

View File

@ -358,10 +358,7 @@ test_expect_success 'empty email' '
test_tick &&
C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) &&
A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) &&
test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" || {
echo "Eh? $A" >failure
false
}
verbose test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700"
'
test_expect_success 'del LF before empty (1)' '

View File

@ -161,10 +161,7 @@ test_expect_success "Michael Cassar's test case" '
git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
T=`git write-tree` &&
git ls-tree -r $T | grep partA/outline.txt || {
git ls-tree -r $T
(exit 1)
}
git ls-tree -r $T | verbose grep partA/outline.txt
'
rm -fr papers partA path?

View File

@ -119,10 +119,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' '
git clean -n ../src |
sed -n -e "s|^Would remove ||p"
) &&
test "$would_clean" = ../src/part3.c || {
echo "OOps <$would_clean>"
false
}
verbose test "$would_clean" = ../src/part3.c
'
test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' '
@ -134,10 +131,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' '
git clean -n "$(pwd)/../src" |
sed -n -e "s|^Would remove ||p"
) &&
test "$would_clean" = ../src/part3.c || {
echo "OOps <$would_clean>"
false
}
verbose test "$would_clean" = ../src/part3.c
'
test_expect_success 'git clean with out of work tree relative path' '