This patch changes every occurrence of "! git" -- with the meaning
that a git call has to gracefully fail -- into "test_must_fail git".
This is useful to
- make sure the test does not fail because of a signal,
e.g. SIGSEGV, and
- advertise the use of "test_must_fail" for new tests.
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Stephan Beyer17 years agocommitted byJunio C Hamano
@ -63,7 +63,7 @@ test_expect_failure 'pretend we have fixed a known breakage' '
@@ -63,7 +63,7 @@ test_expect_failure 'pretend we have fixed a known breakage' '
# updating a new file without --add should fail.
test_expect_success 'git update-index without --add should fail adding.' '
! git update-index should-be-empty
test_must_fail git update-index should-be-empty
'
# and with --add it should succeed, even if it is empty (it used to fail).
@ -43,7 +43,7 @@ test_expect_success "detection of case insensitive filesystem during repo init"
@@ -43,7 +43,7 @@ test_expect_success "detection of case insensitive filesystem during repo init"
else
test_expect_success "detection of case insensitive filesystem during repo init" '
@ -43,7 +43,7 @@ test_expect_success 'git branch c/d should barf if branch c exists' '
@@ -43,7 +43,7 @@ test_expect_success 'git branch c/d should barf if branch c exists' '
@ -35,7 +35,7 @@ test_expect_success 'cherry-pick a non-merge with -m should fail' '
@@ -35,7 +35,7 @@ test_expect_success 'cherry-pick a non-merge with -m should fail' '
git reset --hard &&
git checkout a^0 &&
! git cherry-pick -m 1 b &&
test_must_fail git cherry-pick -m 1 b &&
git diff --exit-code a --
'
@ -44,7 +44,7 @@ test_expect_success 'cherry pick a merge without -m should fail' '
@@ -44,7 +44,7 @@ test_expect_success 'cherry pick a merge without -m should fail' '
git reset --hard &&
git checkout a^0 &&
! git cherry-pick c &&
test_must_fail git cherry-pick c &&
git diff --exit-code a --
'
@ -71,7 +71,7 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f
@@ -71,7 +71,7 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f
git reset --hard &&
git checkout b^0 &&
! git cherry-pick -m 3 c
test_must_fail git cherry-pick -m 3 c
'
@ -79,7 +79,7 @@ test_expect_success 'revert a non-merge with -m should fail' '
@@ -79,7 +79,7 @@ test_expect_success 'revert a non-merge with -m should fail' '
git reset --hard &&
git checkout c^0 &&
! git revert -m 1 b &&
test_must_fail git revert -m 1 b &&
git diff --exit-code c
'
@ -88,7 +88,7 @@ test_expect_success 'revert a merge without -m should fail' '
@@ -88,7 +88,7 @@ test_expect_success 'revert a merge without -m should fail' '
git reset --hard &&
git checkout c^0 &&
! git revert c &&
test_must_fail git revert c &&
git diff --exit-code c
'
@ -115,7 +115,7 @@ test_expect_success 'revert a merge relative to nonexistent parent should fail'
@@ -115,7 +115,7 @@ test_expect_success 'revert a merge relative to nonexistent parent should fail'
test_expect_success 'Re-add foo and baz for HEAD tests' '
@ -173,7 +173,7 @@ test_expect_success 'Re-add foo and baz for HEAD tests' '
@@ -173,7 +173,7 @@ test_expect_success 'Re-add foo and baz for HEAD tests' '
'
test_expect_success 'foo is different in index from HEAD -- rm should refuse' '
! git rm foo baz &&
test_must_fail git rm foo baz &&
test -f foo &&
test -f baz &&
git ls-files --error-unmatch foo baz
@ -183,8 +183,8 @@ test_expect_success 'but with -f it should work.' '
@@ -183,8 +183,8 @@ test_expect_success 'but with -f it should work.' '
git rm -f foo baz &&
test ! -f foo &&
test ! -f baz &&
! git ls-files --error-unmatch foo
! git ls-files --error-unmatch baz
test_must_fail git ls-files --error-unmatch foo
test_must_fail git ls-files --error-unmatch baz
'
test_expect_success 'Recursive test setup' '
@ -195,14 +195,14 @@ test_expect_success 'Recursive test setup' '
@@ -195,14 +195,14 @@ test_expect_success 'Recursive test setup' '
'
test_expect_success 'Recursive without -r fails' '
! git rm frotz &&
test_must_fail git rm frotz &&
test -d frotz &&
test -f frotz/nitfol
'
test_expect_success 'Recursive with -r but dirty' '
echo qfwfq >>frotz/nitfol
! git rm -r frotz &&
test_must_fail git rm -r frotz &&
test -d frotz &&
test -f frotz/nitfol
'
@ -214,7 +214,7 @@ test_expect_success 'Recursive with -r -f' '
@@ -214,7 +214,7 @@ test_expect_success 'Recursive with -r -f' '
@ -144,7 +144,7 @@ test_expect_success 'check with no whitespace errors' '
@@ -144,7 +144,7 @@ test_expect_success 'check with no whitespace errors' '
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
! git diff --check
test_must_fail git diff --check
'
@ -152,7 +152,7 @@ test_expect_success 'check with space before tab in indent' '
@@ -152,7 +152,7 @@ test_expect_success 'check with space before tab in indent' '
@ -190,7 +190,7 @@ test_expect_success 'check staged with space before tab in indent' '
@@ -190,7 +190,7 @@ test_expect_success 'check staged with space before tab in indent' '
@ -215,7 +215,7 @@ test_expect_success 'check with space before tab in indent (diff-index)' '
@@ -215,7 +215,7 @@ test_expect_success 'check with space before tab in indent (diff-index)' '
test_must_fail git diff-index --cached --check HEAD
'
@ -240,7 +240,7 @@ test_expect_success 'check staged with space before tab in indent (diff-index)'
@@ -240,7 +240,7 @@ test_expect_success 'check staged with space before tab in indent (diff-index)'
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
! git diff-index --cached --check HEAD
test_must_fail git diff-index --cached --check HEAD
@ -265,7 +265,7 @@ test_expect_success 'check with space before tab in indent (diff-tree)' '
@@ -265,7 +265,7 @@ test_expect_success 'check with space before tab in indent (diff-tree)' '
@ -299,7 +299,7 @@ test_expect_success 'check space before tab in indent (space-before-tab: on)' '
@@ -299,7 +299,7 @@ test_expect_success 'check space before tab in indent (space-before-tab: on)' '
@ -212,13 +212,13 @@ test_expect_success 'am takes patches from a Pine mailbox' '
@@ -212,13 +212,13 @@ test_expect_success 'am takes patches from a Pine mailbox' '
'
test_expect_success 'am fails on mail without patch' '
@ -320,7 +320,7 @@ test_expect_success '"remote show" does not show symbolic refs' '
@@ -320,7 +320,7 @@ test_expect_success '"remote show" does not show symbolic refs' '
test_expect_success 'reject adding remote with an invalid name' '
@ -104,7 +104,7 @@ test_expect_success 'fetch must not resolve short tag name' '
@@ -104,7 +104,7 @@ test_expect_success 'fetch must not resolve short tag name' '
cd five &&
git init &&
! git fetch .. anno:five
test_must_fail git fetch .. anno:five
'
@ -117,7 +117,7 @@ test_expect_success 'fetch must not resolve short remote name' '
@@ -117,7 +117,7 @@ test_expect_success 'fetch must not resolve short remote name' '
@ -374,7 +374,7 @@ test_expect_success 'push with +HEAD' '
@@ -374,7 +374,7 @@ test_expect_success 'push with +HEAD' '
# Without force rewinding should fail
git reset --hard HEAD^ &&
! git push testrepo HEAD &&
test_must_fail git push testrepo HEAD &&
check_push_result $the_commit heads/local &&
# With force rewinding should succeed
@ -448,7 +448,7 @@ test_expect_success 'push does not update local refs on failure' '
@@ -448,7 +448,7 @@ test_expect_success 'push does not update local refs on failure' '
@ -30,17 +30,17 @@ test_expect_success 'looking for a tag in an empty tree should fail' \
@@ -30,17 +30,17 @@ test_expect_success 'looking for a tag in an empty tree should fail' \
'! (tag_exists mytag)'
test_expect_success 'creating a tag in an empty tree should fail' '
! git-tag mynotag &&
test_must_fail git-tag mynotag &&
! tag_exists mynotag
'
test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
! git-tag mytaghead HEAD &&
test_must_fail git-tag mytaghead HEAD &&
! tag_exists mytaghead
'
test_expect_success 'creating a tag for an unknown revision should fail' '
'trying to create a tag with the name of one existing should fail' \
'! git tag mytag'
'test_must_fail git tag mytag'
test_expect_success \
'trying to create a tag with a non-valid name should fail' '
test `git-tag -l | wc -l` -eq 1 &&
! git tag "" &&
! git tag .othertag &&
! git tag "other tag" &&
! git tag "othertag^" &&
! git tag "other~tag" &&
test_must_fail git tag "" &&
test_must_fail git tag .othertag &&
test_must_fail git tag "other tag" &&
test_must_fail git tag "othertag^" &&
test_must_fail git tag "other~tag" &&
test `git-tag -l | wc -l` -eq 1
'
@ -107,7 +107,7 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
@@ -107,7 +107,7 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
test_expect_success 'trying to delete an unknown tag should fail' '
@ -730,10 +732,11 @@ test_expect_success 'verifying two signed tags in one command should succeed' \
@@ -730,10 +732,11 @@ test_expect_success 'verifying two signed tags in one command should succeed' \
test_expect_success \
'verifying many signed and non-signed tags should fail' '
test_expect_success 'verifying a forged tag should fail' '
@ -741,7 +744,7 @@ test_expect_success 'verifying a forged tag should fail' '
@@ -741,7 +744,7 @@ test_expect_success 'verifying a forged tag should fail' '
@ -63,29 +63,29 @@ test_expect_success 'reset --soft with unmerged index should fail' '
@@ -63,29 +63,29 @@ test_expect_success 'reset --soft with unmerged index should fail' '
printf "1st line 2nd file\n2nd line 2nd file\n3rd line" >secondfile &&
git commit -a -m "the line in branch3" &&
@ -326,7 +326,7 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
@@ -326,7 +326,7 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
test_must_fail git reset HEAD -- file1 file2 file3 &&
git diff > output &&
test_cmp output expect &&
git diff --cached > output &&
@ -402,11 +402,11 @@ test_expect_success 'test resetting the index at give paths' '
@@ -402,11 +402,11 @@ test_expect_success 'test resetting the index at give paths' '
@ -23,12 +23,12 @@ test_expect_success 'a basic commit in an empty tree should succeed' '
@@ -23,12 +23,12 @@ test_expect_success 'a basic commit in an empty tree should succeed' '
test_expect_success 'nonexistent template file should return error' '
@ -216,7 +216,7 @@ test_expect_success "$name" "test_cmp a expected"
@@ -216,7 +216,7 @@ test_expect_success "$name" "test_cmp a expected"
test_expect_success 'exit if remote refs are ambigious' "
git config --add svn-remote.svn.fetch \
bar:refs/remotes/git-svn &&
! git-svn migrate
test_must_fail git-svn migrate
"
test_expect_success 'exit if init-ing a would clobber a URL' '
@ -224,7 +224,7 @@ test_expect_success 'exit if init-ing a would clobber a URL' '
@@ -224,7 +224,7 @@ test_expect_success 'exit if init-ing a would clobber a URL' '
test_expect_success 'commit conflicting change from git' '
echo second line from git >> file &&
git commit -a -m "second line from git" &&
! git-svn commit-diff -r1 HEAD~1 HEAD "$svnrepo"
test_must_fail git-svn commit-diff -r1 HEAD~1 HEAD "$svnrepo"
'
test_expect_success 'commit complementing change from git' '
@ -52,7 +52,7 @@ test_expect_success 'dcommit fails to commit because of conflict' '
@@ -52,7 +52,7 @@ test_expect_success 'dcommit fails to commit because of conflict' '
rm -rf t.svn &&
echo "fourth line from git" >> file &&
git commit -a -m "fourth line from git" &&
! git-svn dcommit
test_must_fail git-svn dcommit
'
test_expect_success 'dcommit does the svn equivalent of an index merge' "
@ -83,7 +83,7 @@ test_expect_success 'multiple dcommit from git-svn will not clobber svn' "
@@ -83,7 +83,7 @@ test_expect_success 'multiple dcommit from git-svn will not clobber svn' "