t7004: Use prerequisite tags to skip tests that need gpg
The tests are skipped if no gpg was found or if gpg is version 1.0.6. Previously, the latter condition was checked a bit later in the test file so that the tag verification tests would be exercised. These are now skipped as well, but only because we would need a facility to revoke a test prerequisite, which we do not have. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Johannes Sixt committed
Mar 16, 2009 at 15:09 UTC
a4df22ce49d0457f3dbec5083064f9d24e4d17dd
1 file changed
+48
-49
t/t7004-tag.sh
+48
-49
@@ -581,28 +581,38 @@ test_expect_success \
581
'
582
583
# subsequent tests require gpg; check if it is available
584
-gpg --version >/dev/null
584
+gpg --version >/dev/null 2>/dev/null
585
if [ $? -eq 127 ]; then
586
say "gpg not found - skipping tag signing and verification tests"
587
- test_done
588
- exit
587
+else
588
+ # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
589
+ # the gpg version 1.0.6 didn't parse trust packets correctly, so for
590
+ # that version, creation of signed tags using the generated key fails.
591
+ case "$(gpg --version)" in
592
+ 'gpg (GnuPG) 1.0.6'*)
593
+ say "Skipping signed tag tests, because a bug in 1.0.6 version"
594
+ ;;
595
+ *)
596
+ test_set_prereq GPG
597
+ ;;
598
+ esac
599
fi
600
601
# trying to verify annotated non-signed tags:
602
593
-test_expect_success \
603
+test_expect_success GPG \
604
'trying to verify an annotated non-signed tag should fail' '
605
tag_exists annotated-tag &&
606
test_must_fail git tag -v annotated-tag
607
'
608
599
-test_expect_success \
609
+test_expect_success GPG \
610
'trying to verify a file-annotated non-signed tag should fail' '
611
tag_exists file-annotated-tag &&
612
test_must_fail git tag -v file-annotated-tag
613
'
614
605
-test_expect_success \
615
+test_expect_success GPG \
616
'trying to verify two annotated non-signed tags should fail' '
617
tag_exists annotated-tag file-annotated-tag &&
618
test_must_fail git tag -v annotated-tag file-annotated-tag
@@ -610,17 +620,6 @@ test_expect_success \
620
621
# creating and verifying signed tags:
622
613
-# As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
614
-# the gpg version 1.0.6 didn't parse trust packets correctly, so for
615
-# that version, creation of signed tags using the generated key fails.
616
-case "$(gpg --version)" in
617
-'gpg (GnuPG) 1.0.6'*)
618
- say "Skipping signed tag tests, because a bug in 1.0.6 version"
619
- test_done
620
- exit
621
- ;;
622
-esac
623
-
623
# key generation info: gpg --homedir t/t7004 --gen-key
624
# Type DSA and Elgamal, size 2048 bits, no expiration date.
625
# Name and email: C O Mitter <committer@example.com>
@@ -634,7 +633,7 @@ export GNUPGHOME
633
get_tag_header signed-tag $commit commit $time >expect
634
echo 'A signed tag message' >>expect
635
echo '-----BEGIN PGP SIGNATURE-----' >>expect
637
-test_expect_success 'creating a signed tag with -m message should succeed' '
636
+test_expect_success GPG 'creating a signed tag with -m message should succeed' '
637
git tag -s -m "A signed tag message" signed-tag &&
638
get_tag_msg signed-tag >actual &&
639
test_cmp expect actual
@@ -643,7 +642,7 @@ test_expect_success 'creating a signed tag with -m message should succeed' '
642
get_tag_header u-signed-tag $commit commit $time >expect
643
echo 'Another message' >>expect
644
echo '-----BEGIN PGP SIGNATURE-----' >>expect
646
-test_expect_success 'sign with a given key id' '
645
+test_expect_success GPG 'sign with a given key id' '
646
647
git tag -u committer@example.com -m "Another message" u-signed-tag &&
648
get_tag_msg u-signed-tag >actual &&
@@ -651,14 +650,14 @@ test_expect_success 'sign with a given key id' '
650
651
'
652
654
-test_expect_success 'sign with an unknown id (1)' '
653
+test_expect_success GPG 'sign with an unknown id (1)' '
654
655
test_must_fail git tag -u author@example.com \
656
-m "Another message" o-signed-tag
657
658
'
659
661
-test_expect_success 'sign with an unknown id (2)' '
660
+test_expect_success GPG 'sign with an unknown id (2)' '
661
662
test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
663
@@ -675,7 +674,7 @@ chmod +x fakeeditor
674
get_tag_header implied-sign $commit commit $time >expect
675
./fakeeditor >>expect
676
echo '-----BEGIN PGP SIGNATURE-----' >>expect
678
-test_expect_success '-u implies signed tag' '
677
+test_expect_success GPG '-u implies signed tag' '
678
GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
679
get_tag_msg implied-sign >actual &&
680
test_cmp expect actual
@@ -688,7 +687,7 @@ EOF
687
get_tag_header file-signed-tag $commit commit $time >expect
688
cat sigmsgfile >>expect
689
echo '-----BEGIN PGP SIGNATURE-----' >>expect
691
-test_expect_success \
690
+test_expect_success GPG \
691
'creating a signed tag with -F messagefile should succeed' '
692
git tag -s -F sigmsgfile file-signed-tag &&
693
get_tag_msg file-signed-tag >actual &&
@@ -702,7 +701,7 @@ EOF
701
get_tag_header stdin-signed-tag $commit commit $time >expect
702
cat siginputmsg >>expect
703
echo '-----BEGIN PGP SIGNATURE-----' >>expect
705
-test_expect_success 'creating a signed tag with -F - should succeed' '
704
+test_expect_success GPG 'creating a signed tag with -F - should succeed' '
705
git tag -s -F - stdin-signed-tag <siginputmsg &&
706
get_tag_msg stdin-signed-tag >actual &&
707
test_cmp expect actual
@@ -711,13 +710,13 @@ test_expect_success 'creating a signed tag with -F - should succeed' '
710
get_tag_header implied-annotate $commit commit $time >expect
711
./fakeeditor >>expect
712
echo '-----BEGIN PGP SIGNATURE-----' >>expect
714
-test_expect_success '-s implies annotated tag' '
713
+test_expect_success GPG '-s implies annotated tag' '
714
GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
715
get_tag_msg implied-annotate >actual &&
716
test_cmp expect actual
717
'
718
720
-test_expect_success \
719
+test_expect_success GPG \
720
'trying to create a signed tag with non-existing -F file should fail' '
721
! test -f nonexistingfile &&
722
! tag_exists nosigtag &&
@@ -725,13 +724,13 @@ test_expect_success \
724
! tag_exists nosigtag
725
'
726
728
-test_expect_success 'verifying a signed tag should succeed' \
727
+test_expect_success GPG 'verifying a signed tag should succeed' \
728
'git tag -v signed-tag'
729
731
-test_expect_success 'verifying two signed tags in one command should succeed' \
730
+test_expect_success GPG 'verifying two signed tags in one command should succeed' \
731
'git tag -v signed-tag file-signed-tag'
732
734
-test_expect_success \
733
+test_expect_success GPG \
734
'verifying many signed and non-signed tags should fail' '
735
test_must_fail git tag -v signed-tag annotated-tag &&
736
test_must_fail git tag -v file-annotated-tag file-signed-tag &&
@@ -740,7 +739,7 @@ test_expect_success \
739
test_must_fail git tag -v signed-tag annotated-tag file-signed-tag
740
'
741
743
-test_expect_success 'verifying a forged tag should fail' '
742
+test_expect_success GPG 'verifying a forged tag should fail' '
743
forged=$(git cat-file tag signed-tag |
744
sed -e "s/signed-tag/forged-tag/" |
745
git mktag) &&
@@ -752,7 +751,7 @@ test_expect_success 'verifying a forged tag should fail' '
751
752
get_tag_header empty-signed-tag $commit commit $time >expect
753
echo '-----BEGIN PGP SIGNATURE-----' >>expect
755
-test_expect_success \
754
+test_expect_success GPG \
755
'creating a signed tag with an empty -m message should succeed' '
756
git tag -s -m "" empty-signed-tag &&
757
get_tag_msg empty-signed-tag >actual &&
@@ -763,7 +762,7 @@ test_expect_success \
762
>sigemptyfile
763
get_tag_header emptyfile-signed-tag $commit commit $time >expect
764
echo '-----BEGIN PGP SIGNATURE-----' >>expect
766
-test_expect_success \
765
+test_expect_success GPG \
766
'creating a signed tag with an empty -F messagefile should succeed' '
767
git tag -s -F sigemptyfile emptyfile-signed-tag &&
768
get_tag_msg emptyfile-signed-tag >actual &&
@@ -786,7 +785,7 @@ Trailing spaces
785
Trailing blank lines
786
EOF
787
echo '-----BEGIN PGP SIGNATURE-----' >>expect
789
-test_expect_success \
788
+test_expect_success GPG \
789
'extra blanks in the message for a signed tag should be removed' '
790
git tag -s -F sigblanksfile blanks-signed-tag &&
791
get_tag_msg blanks-signed-tag >actual &&
@@ -796,7 +795,7 @@ test_expect_success \
795
796
get_tag_header blank-signed-tag $commit commit $time >expect
797
echo '-----BEGIN PGP SIGNATURE-----' >>expect
799
-test_expect_success \
798
+test_expect_success GPG \
799
'creating a signed tag with a blank -m message should succeed' '
800
git tag -s -m " " blank-signed-tag &&
801
get_tag_msg blank-signed-tag >actual &&
@@ -809,7 +808,7 @@ echo '' >>sigblankfile
808
echo ' ' >>sigblankfile
809
get_tag_header blankfile-signed-tag $commit commit $time >expect
810
echo '-----BEGIN PGP SIGNATURE-----' >>expect
812
-test_expect_success \
811
+test_expect_success GPG \
812
'creating a signed tag with blank -F file with spaces should succeed' '
813
git tag -s -F sigblankfile blankfile-signed-tag &&
814
get_tag_msg blankfile-signed-tag >actual &&
@@ -820,7 +819,7 @@ test_expect_success \
819
printf ' ' >sigblanknonlfile
820
get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
821
echo '-----BEGIN PGP SIGNATURE-----' >>expect
823
-test_expect_success \
822
+test_expect_success GPG \
823
'creating a signed tag with spaces and no newline should succeed' '
824
git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
825
get_tag_msg blanknonlfile-signed-tag >actual &&
@@ -857,7 +856,7 @@ Another line.
856
Last line.
857
EOF
858
echo '-----BEGIN PGP SIGNATURE-----' >>expect
860
-test_expect_success \
859
+test_expect_success GPG \
860
'creating a signed tag with a -F file with #comments should succeed' '
861
git tag -s -F sigcommentsfile comments-signed-tag &&
862
get_tag_msg comments-signed-tag >actual &&
@@ -867,7 +866,7 @@ test_expect_success \
866
867
get_tag_header comment-signed-tag $commit commit $time >expect
868
echo '-----BEGIN PGP SIGNATURE-----' >>expect
870
-test_expect_success \
869
+test_expect_success GPG \
870
'creating a signed tag with #commented -m message should succeed' '
871
git tag -s -m "#comment" comment-signed-tag &&
872
get_tag_msg comment-signed-tag >actual &&
@@ -880,7 +879,7 @@ echo '' >>sigcommentfile
879
echo '####' >>sigcommentfile
880
get_tag_header commentfile-signed-tag $commit commit $time >expect
881
echo '-----BEGIN PGP SIGNATURE-----' >>expect
883
-test_expect_success \
882
+test_expect_success GPG \
883
'creating a signed tag with #commented -F messagefile should succeed' '
884
git tag -s -F sigcommentfile commentfile-signed-tag &&
885
get_tag_msg commentfile-signed-tag >actual &&
@@ -891,7 +890,7 @@ test_expect_success \
890
printf '#comment' >sigcommentnonlfile
891
get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
892
echo '-----BEGIN PGP SIGNATURE-----' >>expect
894
-test_expect_success \
893
+test_expect_success GPG \
894
'creating a signed tag with a #comment and no newline should succeed' '
895
git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
896
get_tag_msg commentnonlfile-signed-tag >actual &&
@@ -901,7 +900,7 @@ test_expect_success \
900
901
# listing messages for signed tags:
902
904
-test_expect_success \
903
+test_expect_success GPG \
904
'listing the one-line message of a signed tag should succeed' '
905
git tag -s -m "A message line signed" stag-one-line &&
906
@@ -926,7 +925,7 @@ test_expect_success \
925
test_cmp expect actual
926
'
927
929
-test_expect_success \
928
+test_expect_success GPG \
929
'listing the zero-lines message of a signed tag should succeed' '
930
git tag -s -m "" stag-zero-lines &&
931
@@ -954,7 +953,7 @@ test_expect_success \
953
echo 'stag line one' >sigtagmsg
954
echo 'stag line two' >>sigtagmsg
955
echo 'stag line three' >>sigtagmsg
957
-test_expect_success \
956
+test_expect_success GPG \
957
'listing many message lines of a signed tag should succeed' '
958
git tag -s -F sigtagmsg stag-lines &&
959
@@ -999,12 +998,12 @@ test_expect_success \
998
999
tree=$(git rev-parse HEAD^{tree})
1000
blob=$(git rev-parse HEAD:foo)
1002
-tag=$(git rev-parse signed-tag)
1001
+tag=$(git rev-parse signed-tag 2>/dev/null)
1002
1003
get_tag_header tree-signed-tag $tree tree $time >expect
1004
echo "A message for a tree" >>expect
1005
echo '-----BEGIN PGP SIGNATURE-----' >>expect
1007
-test_expect_success \
1006
+test_expect_success GPG \
1007
'creating a signed tag pointing to a tree should succeed' '
1008
git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
1009
get_tag_msg tree-signed-tag >actual &&
@@ -1014,7 +1013,7 @@ test_expect_success \
1013
get_tag_header blob-signed-tag $blob blob $time >expect
1014
echo "A message for a blob" >>expect
1015
echo '-----BEGIN PGP SIGNATURE-----' >>expect
1017
-test_expect_success \
1016
+test_expect_success GPG \
1017
'creating a signed tag pointing to a blob should succeed' '
1018
git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
1019
get_tag_msg blob-signed-tag >actual &&
@@ -1024,7 +1023,7 @@ test_expect_success \
1023
get_tag_header tag-signed-tag $tag tag $time >expect
1024
echo "A message for another tag" >>expect
1025
echo '-----BEGIN PGP SIGNATURE-----' >>expect
1027
-test_expect_success \
1026
+test_expect_success GPG \
1027
'creating a signed tag pointing to another tag should succeed' '
1028
git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
1029
get_tag_msg tag-signed-tag >actual &&
@@ -1033,7 +1032,7 @@ test_expect_success \
1032
1033
# try to sign with bad user.signingkey
1034
git config user.signingkey BobTheMouse
1036
-test_expect_success \
1035
+test_expect_success GPG \
1036
'git tag -s fails if gpg is misconfigured' \
1037
'test_must_fail git tag -s -m tail tag-gpg-failure'
1038
git config --unset user.signingkey
@@ -1041,7 +1040,7 @@ git config --unset user.signingkey
1040
# try to verify without gpg:
1041
1042
rm -rf gpghome
1044
-test_expect_success \
1043
+test_expect_success GPG \
1044
'verify signed tag fails when public key is not present' \
1045
'test_must_fail git tag -v signed-tag'
1046