t: use test_expect_code instead of hand-rolled comparison
This makes our output in the event of a failure slightly nicer, and it means that we do not break the &&-chain. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
35da1bf5d6
commit
c21fc9d0ab
@ -172,12 +172,9 @@ test_expect_success 'long options' '
|
||||
'
|
||||
|
||||
test_expect_success 'missing required value' '
|
||||
test-parse-options -s;
|
||||
test $? = 129 &&
|
||||
test-parse-options --string;
|
||||
test $? = 129 &&
|
||||
test-parse-options --file;
|
||||
test $? = 129
|
||||
test_expect_code 129 test-parse-options -s &&
|
||||
test_expect_code 129 test-parse-options --string &&
|
||||
test_expect_code 129 test-parse-options --file
|
||||
'
|
||||
|
||||
cat > expect << EOF
|
||||
@ -227,8 +224,7 @@ test_expect_success 'unambiguously abbreviated option with "="' '
|
||||
'
|
||||
|
||||
test_expect_success 'ambiguously abbreviated option' '
|
||||
test-parse-options --strin 123;
|
||||
test $? = 129
|
||||
test_expect_code 129 test-parse-options --strin 123
|
||||
'
|
||||
|
||||
cat > expect << EOF
|
||||
|
@ -29,67 +29,65 @@ test_expect_success 'setup' '
|
||||
'
|
||||
|
||||
test_expect_success 'git diff-tree HEAD^ HEAD' '
|
||||
git diff-tree --quiet HEAD^ HEAD >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
|
||||
git diff-tree --quiet HEAD^ HEAD -- a >cnt
|
||||
test $? = 0 && test_line_count = 0 cnt
|
||||
test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
|
||||
git diff-tree --quiet HEAD^ HEAD -- b >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
# this diff outputs one line: sha1 of the given head
|
||||
test_expect_success 'echo HEAD | git diff-tree --stdin' '
|
||||
echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt
|
||||
test $? = 1 && test_line_count = 1 cnt
|
||||
echo $(git rev-parse HEAD) |
|
||||
test_expect_code 1 git diff-tree --quiet --stdin >cnt &&
|
||||
test_line_count = 1 cnt
|
||||
'
|
||||
test_expect_success 'git diff-tree HEAD HEAD' '
|
||||
git diff-tree --quiet HEAD HEAD >cnt
|
||||
test $? = 0 && test_line_count = 0 cnt
|
||||
test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-files' '
|
||||
git diff-files --quiet >cnt
|
||||
test $? = 0 && test_line_count = 0 cnt
|
||||
test_expect_code 0 git diff-files --quiet >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-index --cached HEAD' '
|
||||
git diff-index --quiet --cached HEAD >cnt
|
||||
test $? = 0 && test_line_count = 0 cnt
|
||||
test_expect_code 0 git diff-index --quiet --cached HEAD >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-index --cached HEAD^' '
|
||||
git diff-index --quiet --cached HEAD^ >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-index --cached HEAD^' '
|
||||
echo text >>b &&
|
||||
echo 3 >c &&
|
||||
git add . && {
|
||||
git diff-index --quiet --cached HEAD^ >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
}
|
||||
git add . &&
|
||||
test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
|
||||
git commit -m "text in b" && {
|
||||
git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
}
|
||||
git commit -m "text in b" &&
|
||||
test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
|
||||
git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt
|
||||
test $? = 0 && test_line_count = 0 cnt
|
||||
test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
test_expect_success 'git diff-files' '
|
||||
echo 3 >>c && {
|
||||
git diff-files --quiet >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
}
|
||||
echo 3 >>c &&
|
||||
test_expect_code 1 git diff-files --quiet >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
|
||||
test_expect_success 'git diff-index --cached HEAD' '
|
||||
git update-index c && {
|
||||
git diff-index --quiet --cached HEAD >cnt
|
||||
test $? = 1 && test_line_count = 0 cnt
|
||||
}
|
||||
git update-index c &&
|
||||
test_expect_code 1 git diff-index --quiet --cached HEAD >cnt &&
|
||||
test_line_count = 0 cnt
|
||||
'
|
||||
|
||||
test_expect_success 'git diff, one file outside repo' '
|
||||
|
@ -17,8 +17,8 @@ test_expect_success 'setup' '
|
||||
'
|
||||
|
||||
test_expect_success 'git diff --no-index directories' '
|
||||
git diff --no-index a b >cnt
|
||||
test $? = 1 && test_line_count = 14 cnt
|
||||
test_expect_code 1 git diff --no-index a b >cnt &&
|
||||
test_line_count = 14 cnt
|
||||
'
|
||||
|
||||
test_expect_success 'git diff --no-index relative path outside repo' '
|
||||
|
Loading…
Reference in New Issue
Block a user