Re: [PATCH 2/2] tests(gpg): increase verbosity to allow debugging
- From
Jeff King <peff@peff.net>
- Date
- Mar 23, 2020, 17:32 UTC
- Message-ID
- <20200323173258.GA3977@coredump.intra.peff.net>
- In-Reply-To
- <dd26cb05a37a54d9d245823772d33fe0daab8ffa.1584968990.git.gitgitgadget@gmail.com>
On Mon, Mar 23, 2020 at 01:09:50PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 16 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de> > > 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 redirecting the output not to `/dev/null`, but to the > file descriptors that may, or may not, be redirected via > `--verbose-log`. For good measure, also turn on tracing if the user > asked for it, and prefix it with a helpful info message.
It definitely makes sense for this info to be shown in verbose (and "-x") mode. I'm OK with this patch as easiest way to get from A to B, but I think the existing code shows a bit of an anti-pattern: trying to do too much outside of test blocks where verbosity and tracing is already handled.
In this case if the whole thing were in a "test_lazy_prereq" we would have gotten all that for free. I don't think the laziness would matter too much in practice, though it is a little funny that it has side effects (like setting up $GPGHOME). Having an immediate version like "test_check_prereq" would make sense to me.
I don't know if it's worth re-doing this patch (I'll leave that decision to you). But something to keep in mind when we run into similar situations (or are writing new prereq code).
-Peff