@matheusbsbs / matheus-bagliano / commits / 2b60649113
Fork 0

tests: increase the verbosity of the GPG-related prereqs

Especially when debugging a test failure that can only be reproduced in the CI build (e.g. when the developer has no access to a macOS machine other than running the tests on a macOS build agent), output should not be suppressed. In the instance of `hi/gpg-prefer-check-signature`, where one GPG-related test failed for no apparent reason, the entire output of `gpg` and `gpgsm` was suppressed, even in verbose mode, leaving interested readers no clue what was going wrong. Let's fix this by no longer redirecting the output not to `/dev/null`. This is now possible because the affected prereqs were turned into lazy ones (and are therefore evaluated via `test_eval_` which respects the `--verbose` option). Note that we _still_ redirect `stdout` to `/dev/null` for those commands that sign their `stdin`, as the output would be binary (and useless anyway, because the reader would not have anything against which to compare the output). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Mar 26, 2020 at 15:35 UTC 2b60649113b50d8dd288f4416d234ca27d31565f
1 file changed +14 -14
t/lib-gpg.sh
+14 -14
@@ -40,12 +40,12 @@ test_lazy_prereq GPG '
40 # > lib-gpg/ownertrust
41 mkdir "$GNUPGHOME" &&
42 chmod 0700 "$GNUPGHOME" &&
43 - (gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
44 - gpg --homedir "${GNUPGHOME}" 2>/dev/null --import \
43 + (gpgconf --kill gpg-agent || : ) &&
44 + gpg --homedir "${GNUPGHOME}" --import \
45 "$TEST_DIRECTORY"/lib-gpg/keyring.gpg &&
46 - gpg --homedir "${GNUPGHOME}" 2>/dev/null --import-ownertrust \
46 + gpg --homedir "${GNUPGHOME}" --import-ownertrust \
47 "$TEST_DIRECTORY"/lib-gpg/ownertrust &&
48 - gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null 2>&1 \
48 + gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null \
49 --sign -u committer@example.com
50 ;;
51 esac
@@ -68,23 +68,23 @@ test_lazy_prereq GPGSM '
68 # gpgsm --homedir /tmp/gpghome/ \
69 # -o t/lib-gpg/gpgsm_cert.p12 \
70 # --export-secret-key-p12 "committer@example.com"
71 - echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
72 - --passphrase-fd 0 --pinentry-mode loopback \
73 - --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
71 + echo | gpgsm --homedir "${GNUPGHOME}" \
72 + --passphrase-fd 0 --pinentry-mode loopback \
73 + --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
74
75 - gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
76 - grep fingerprint: |
77 - cut -d" " -f4 |
75 + gpgsm --homedir "${GNUPGHOME}" -K |
76 + grep fingerprint: |
77 + cut -d" " -f4 |
78 tr -d "\\n" >"${GNUPGHOME}/trustlist.txt" &&
79
80 - echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
81 - echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
82 - -u committer@example.com -o /dev/null --sign - 2>&1
80 + echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
81 + echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
82 + -u committer@example.com -o /dev/null --sign -
83 '
84
85 test_lazy_prereq RFC1991 '
86 test_have_prereq GPG &&
87 - echo | gpg --homedir "${GNUPGHOME}" -b --rfc1991 >/dev/null 2>&1
87 + echo | gpg --homedir "${GNUPGHOME}" -b --rfc1991 >/dev/null
88 '
89
90 sanitize_pgp() {