Originally, test_expect_failure was designed to be the opposite
of test_expect_success, but this was a bad decision. Most tests
run a series of commands that leads to the single command that
needs to be tested, like this:
test_expect_{success,failure} 'test title' '
setup1 &&
setup2 &&
setup3 &&
what is to be tested
'
And expecting a failure exit from the whole sequence misses the
point of writing tests. Your setup$N that are supposed to
succeed may have failed without even reaching what you are
trying to test. The only valid use of test_expect_failure is to
check a trivial single command that is expected to fail, which
is a minority in tests of Porcelain-ish commands.
This large-ish patch rewrites all uses of test_expect_failure to
use test_expect_success and rewrites the condition of what is
tested, like this:
test_expect_success 'test title' '
setup1 &&
setup2 &&
setup3 &&
! this command should fail
'
test_expect_failure is redefined to serve as a reminder that
that test *should* succeed but due to a known breakage in git it
currently does not pass. So if git-foo command should create a
file 'bar' but you discovered a bug that it doesn't, you can
write a test like this:
test_expect_failure 'git-foo should create bar' '
rm -f bar &&
git foo &&
test -f bar
'
This construct acts similar to test_expect_success, but instead
of reporting "ok/FAIL" like test_expect_success does, the
outcome is reported as "FIXED/still broken".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
@ -210,12 +210,12 @@ DF (file) when tree B require DF to be a directory by having DF/DF
@@ -210,12 +210,12 @@ DF (file) when tree B require DF to be a directory by having DF/DF
END_OF_CASE_TABLE
test_expect_failure \
'1 - must not have an entry not in A.' \
"rm -f .git/index XX &&
test_expect_success '1 - must not have an entry not in A.' "
@ -95,7 +95,7 @@ test_expect_success 'fetch following tags' '
@@ -95,7 +95,7 @@ test_expect_success 'fetch following tags' '
'
test_expect_failure 'fetch must not resolve short tag name' '
test_expect_success 'fetch must not resolve short tag name' '
cd "$D" &&
@ -103,11 +103,11 @@ test_expect_failure 'fetch must not resolve short tag name' '
@@ -103,11 +103,11 @@ test_expect_failure 'fetch must not resolve short tag name' '
cd five &&
git init &&
git fetch .. anno:five
! git fetch .. anno:five
'
test_expect_failure 'fetch must not resolve short remote name' '
test_expect_success 'fetch must not resolve short remote name' '
cd "$D" &&
git-update-ref refs/remotes/six/HEAD HEAD
@ -116,7 +116,7 @@ test_expect_failure 'fetch must not resolve short remote name' '
@@ -116,7 +116,7 @@ test_expect_failure 'fetch must not resolve short remote name' '
test_expect_success 'Check format specifiers are ignored in naming date atoms' '
@ -63,8 +63,8 @@ test_expect_success 'Check valid format specifiers for date fields' '
@@ -63,8 +63,8 @@ test_expect_success 'Check valid format specifiers for date fields' '
@ -26,8 +26,8 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
@@ -26,8 +26,8 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
test `git-tag | wc -l` -eq 0
'
test_expect_failure 'looking for a tag in an empty tree should fail' \
'tag_exists mytag'
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' '
test_expect_failure 'dcommit fails to commit because of conflict' "
test_expect_success 'dcommit fails to commit because of conflict' "
git-svn init $svnrepo &&
git-svn fetch &&
git reset --hard refs/remotes/git-svn &&
@ -52,8 +52,8 @@ test_expect_failure 'dcommit fails to commit because of conflict' "
@@ -52,8 +52,8 @@ test_expect_failure '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
" || true
! git-svn dcommit
"
test_expect_success 'dcommit does the svn equivalent of an index merge' "
git reset --hard refs/remotes/git-svn &&
@ -76,15 +76,15 @@ test_expect_success 'commit another change from svn side' "
@@ -76,15 +76,15 @@ test_expect_success 'commit another change from svn side' "
rm -rf t.svn
"
test_expect_failure 'multiple dcommit from git-svn will not clobber svn' "
test_expect_success 'multiple dcommit from git-svn will not clobber svn' "
git reset --hard refs/remotes/git-svn &&
echo new file >> new-file &&
git update-index --add new-file &&
git commit -a -m 'new file' &&
echo clobber > file &&
git commit -a -m 'clobber' &&
git svn dcommit
" || true
! git svn dcommit
"
test_expect_success 'check that rebase really failed' 'test -d .dotest'