t7004: factor out gpg setup

Other test scripts may want to look at or verify signed tags, and the setup is non-trivial. Let's factor this out into lib-gpg.sh for other tests to use. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 7, 2011 at 13:42 UTC 37d3e85912ea13cb1d59022e2bc2ea8cf8bf4876
6 files changed +27 -28
t/lib-gpg.sh new
+26
@@ -0,0 +1,26 @@
1 +#!/bin/sh
2 +
3 +gpg_version=`gpg --version 2>&1`
4 +if test $? = 127; then
5 + say "You do not seem to have gpg installed"
6 +else
7 + # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
8 + # the gpg version 1.0.6 didn't parse trust packets correctly, so for
9 + # that version, creation of signed tags using the generated key fails.
10 + case "$gpg_version" in
11 + 'gpg (GnuPG) 1.0.6'*)
12 + say "Your version of gpg (1.0.6) is too buggy for testing"
13 + ;;
14 + *)
15 + # key generation info: gpg --homedir t/lib-gpg --gen-key
16 + # Type DSA and Elgamal, size 2048 bits, no expiration date.
17 + # Name and email: C O Mitter <committer@example.com>
18 + # No password given, to enable non-interactive operation.
19 + cp -R "$TEST_DIRECTORY"/lib-gpg ./gpghome
20 + chmod 0700 gpghome
21 + GNUPGHOME="$(pwd)/gpghome"
22 + export GNUPGHOME
23 + test_set_prereq GPG
24 + ;;
25 + esac
26 +fi
t/lib-gpg/pubring.gpg renamed
t/lib-gpg/random_seed renamed
t/lib-gpg/secring.gpg renamed
t/lib-gpg/trustdb.gpg renamed
t/t7004-tag.sh
+1 -28
@@ -8,6 +8,7 @@ test_description='git tag
8 Tests for operations with tags.'
9
10 . ./test-lib.sh
11 +. "$TEST_DIRECTORY"/lib-gpg.sh
12
13 # creating and listing lightweight tags:
14
@@ -585,24 +586,6 @@ test_expect_success \
586 test_cmp expect actual
587 '
588
588 -# subsequent tests require gpg; check if it is available
589 -gpg --version >/dev/null 2>/dev/null
590 -if [ $? -eq 127 ]; then
591 - say "# gpg not found - skipping tag signing and verification tests"
592 -else
593 - # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
594 - # the gpg version 1.0.6 didn't parse trust packets correctly, so for
595 - # that version, creation of signed tags using the generated key fails.
596 - case "$(gpg --version)" in
597 - 'gpg (GnuPG) 1.0.6'*)
598 - say "Skipping signed tag tests, because a bug in 1.0.6 version"
599 - ;;
600 - *)
601 - test_set_prereq GPG
602 - ;;
603 - esac
604 -fi
605 -
589 # trying to verify annotated non-signed tags:
590
591 test_expect_success GPG \
@@ -625,16 +608,6 @@ test_expect_success GPG \
608
609 # creating and verifying signed tags:
610
628 -# key generation info: gpg --homedir t/t7004 --gen-key
629 -# Type DSA and Elgamal, size 2048 bits, no expiration date.
630 -# Name and email: C O Mitter <committer@example.com>
631 -# No password given, to enable non-interactive operation.
632 -
633 -cp -R "$TEST_DIRECTORY"/t7004 ./gpghome
634 -chmod 0700 gpghome
635 -GNUPGHOME="$(pwd)/gpghome"
636 -export GNUPGHOME
637 -
611 get_tag_header signed-tag $commit commit $time >expect
612 echo 'A signed tag message' >>expect
613 echo '-----BEGIN PGP SIGNATURE-----' >>expect