]> git.ipfire.org Git - thirdparty/git.git/commit
tests: turn GPG, GPGSM and RFC1991 into lazy prereqs
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 26 Mar 2020 15:35:27 +0000 (15:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Mar 2020 20:36:54 +0000 (13:36 -0700)
commitb417ec5f22e05e4320b338cd48b280008314a691
treea94a7508ae30e3d6370ad6dd6d683f5dd4b926cf
parent477dcaddb6dceb0fc5b5064edef460d9d226386e
tests: turn GPG, GPGSM and RFC1991 into lazy prereqs

The code to set those prereqs is executed completely outside of any
`test_eval_` block. As a consequence, its output had to be suppressed so
that it does not clutter the output of a regular test script run.

Unfortunately, the output *stays* suppressed even when the `--verbose`
option is in effect.

This hid important output when debugging why the GPG prereq was not
enabled in the Windows part of our CI builds.

In preparation for fixing that, let's move all of this code into lazy
prereqs.

The only slightly tricky part is the global environment variable
`GNUPGHOME`. Originally, it was configured only when we verified that
there is a `gpg` in the `PATH` that we can use. This is now no longer
possible, as lazy prereqs are evaluated in a subshell that changes the
working directory to a temporary one. Therefore, we simply _always_ set
that environment variable: it does not hurt anything because it does not
indicate the presence of a working GPG.

Side note: it was quite tempting to use a hack that is possible because
we do not validate what is passed to `test_lazy_prereq` (and it is
therefore possible to "break out" of the lazy_prereq subshell:

test_lazy_prereq GPG '...) && GNUPGHOME=... && (...'

However, this is rather tricksy hobbitses code, and the current patch is
_much_ easier to understand.

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