aboutsummaryrefslogtreecommitdiff
path: root/t/t7004-tag.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-01 01:50:53 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-01 20:49:34 -0800
commit41ac414ea2bef81af94474cbef25a38868b4788e (patch)
treee9c598e65753ab473eefc6fcc5899714d8085a2f /t/t7004-tag.sh
parent6ce8e44a1eeaa07325f1304f6f392f35f54d29c7 (diff)
downloadgit-41ac414ea2bef81af94474cbef25a38868b4788e.tar.gz
git-41ac414ea2bef81af94474cbef25a38868b4788e.tar.xz
Sane use of test_expect_failure
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>
Diffstat (limited to 't/t7004-tag.sh')
-rwxr-xr-xt/t7004-tag.sh36
1 files changed, 18 insertions, 18 deletions
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index df496a95f..75cd33bde 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -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' '
! git-tag mynotag &&
@@ -83,9 +83,9 @@ test_expect_success \
# special cases for creating tags:
-test_expect_failure \
+test_expect_success \
'trying to create a tag with the name of one existing should fail' \
- 'git tag mytag'
+ '! git tag mytag'
test_expect_success \
'trying to create a tag with a non-valid name should fail' '
@@ -146,8 +146,8 @@ test_expect_success \
! tag_exists myhead
'
-test_expect_failure 'trying to delete an already deleted tag should fail' \
- 'git-tag -d mytag'
+test_expect_success 'trying to delete an already deleted tag should fail' \
+ '! git-tag -d mytag'
# listing various tags with pattern matching:
@@ -265,16 +265,16 @@ test_expect_success \
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_failure 'trying to verify an unknown tag should fail' \
- 'git-tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' \
+ '! git-tag -v unknown-tag'
-test_expect_failure \
+test_expect_success \
'trying to verify a non-annotated and non-signed tag should fail' \
- 'git-tag -v non-annotated-tag'
+ '! git-tag -v non-annotated-tag'
-test_expect_failure \
+test_expect_success \
'trying to verify many non-annotated or unknown tags, should fail' \
- 'git-tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+ '! git-tag -v unknown-tag1 non-annotated-tag unknown-tag2'
# creating annotated tags:
@@ -1027,21 +1027,21 @@ test_expect_success \
# try to sign with bad user.signingkey
git config user.signingkey BobTheMouse
-test_expect_failure \
+test_expect_success \
'git-tag -s fails if gpg is misconfigured' \
- 'git tag -s -m tail tag-gpg-failure'
+ '! git tag -s -m tail tag-gpg-failure'
git config --unset user.signingkey
# try to verify without gpg:
rm -rf gpghome
-test_expect_failure \
+test_expect_success \
'verify signed tag fails when public key is not present' \
- 'git-tag -v signed-tag'
+ '! git-tag -v signed-tag'
-test_expect_failure \
+test_expect_success \
'git-tag -a fails if tag annotation is empty' '
- GIT_EDITOR=cat git tag -a initial-comment
+ ! (GIT_EDITOR=cat git tag -a initial-comment)
'
test_expect_success \