]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7510: add a test case that does not need gpg
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 15 Feb 2023 05:58:33 +0000 (05:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Feb 2023 16:55:22 +0000 (08:55 -0800)
This test case not only increases test coverage in setups without
working gpg, but also prepares for verifying that the error message of
`gpg.program` is shown upon failure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7510-signed-commit.sh

index 8593b7e3cb8d9aa0c4badeef4273ed406cecc9ca..24dc3ef0a21980ea822729d57404b5cf258b8b0e 100755 (executable)
@@ -387,4 +387,40 @@ test_expect_success GPG 'verify-commit verifies multiply signed commits' '
        ! grep "BAD signature from" actual
 '
 
+test_expect_success 'custom `gpg.program`' '
+       write_script fake-gpg <<-\EOF &&
+       args="$*"
+
+       # skip uninteresting options
+       while case "$1" in
+       --status-fd=*|--keyid-format=*) ;; # skip
+       *) break;;
+       esac; do shift; done
+
+       case "$1" in
+       -bsau)
+               cat >sign.file
+               echo "[GNUPG:] SIG_CREATED $args" >&2
+               echo "-----BEGIN PGP MESSAGE-----"
+               echo "$args"
+               echo "-----END PGP MESSAGE-----"
+               ;;
+       --verify)
+               cat "$2" >verify.file
+               exit 0
+               ;;
+       *)
+               echo "Unhandled args: $*" >&2
+               exit 1
+               ;;
+       esac
+       EOF
+
+       test_config gpg.program "$(pwd)/fake-gpg" &&
+       git commit -S --allow-empty -m signed-commit &&
+       test_path_exists sign.file &&
+       git show --show-signature &&
+       test_path_exists verify.file
+'
+
 test_done