t7510: add a test case that does not need gpg

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>

Johannes Schindelin committed Feb 15, 2023 at 05:58 UTC 8300d15d5ecea1e41b2b1d381238ccaaec501dd4
1 file changed +36
t/t7510-signed-commit.sh
+36
@@ -387,4 +387,40 @@ test_expect_success GPG 'verify-commit verifies multiply signed commits' '
387 ! grep "BAD signature from" actual
388 '
389
390 +test_expect_success 'custom `gpg.program`' '
391 + write_script fake-gpg <<-\EOF &&
392 + args="$*"
393 +
394 + # skip uninteresting options
395 + while case "$1" in
396 + --status-fd=*|--keyid-format=*) ;; # skip
397 + *) break;;
398 + esac; do shift; done
399 +
400 + case "$1" in
401 + -bsau)
402 + cat >sign.file
403 + echo "[GNUPG:] SIG_CREATED $args" >&2
404 + echo "-----BEGIN PGP MESSAGE-----"
405 + echo "$args"
406 + echo "-----END PGP MESSAGE-----"
407 + ;;
408 + --verify)
409 + cat "$2" >verify.file
410 + exit 0
411 + ;;
412 + *)
413 + echo "Unhandled args: $*" >&2
414 + exit 1
415 + ;;
416 + esac
417 + EOF
418 +
419 + test_config gpg.program "$(pwd)/fake-gpg" &&
420 + git commit -S --allow-empty -m signed-commit &&
421 + test_path_exists sign.file &&
422 + git show --show-signature &&
423 + test_path_exists verify.file
424 +'
425 +
426 test_done