You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test-lib: pass --tee and --verbose{,-log} through a TAP validator
Change the output under --tee and --verbose so that instead of passing
the output through "tee -a" we use our own home-grown "test-tool
tee-tap" (the "--verbose" output only goes through it under
HARNESS_ACTIVE=true, see below).
This ensures the output is valid TAP, allowing our test output to be
machine-readable. The --verbose-log mode is the first consumer of that
machine-readability, see further discussion below.
First, on the history of machine readable TAP output: Both the verbose
and non-verbose test outputs were valid TAP back when I added support
for TAP in 5099b99 (test-lib: Adjust output to be valid TAP
format, 2010-06-24).
Sometime after that the --verbose output broke due to some tests
emitting their own lines starting "ok" (or otherwise invalidating the
TAP). That was noticed and fixed in 452320f (test-lib: add
--verbose-log option, 2016-10-21), the problem was that the fix simply
turned off the the verbose mode when we were running under
TAP::Harness (e.g. under "prove").
That solution worked for running under Travis CI. After that fix it
was made to use the --verbose-log option in 041c72d (travis: use
--verbose-log test option, 2016-10-21), see 522354d (Add Travis CI
support, 2015-11-27) for the "cat t/test-results/*.out" code that was
aimed at.
But that solution and others discussed in 452320f closed the door
on us having reliable machine-readable TAP output.
Let's instead revert the work done in 452320f and, as well as the
follow-up commits 88c6e9d (test-lib: --valgrind should not override
--verbose-log, 2017-09-05) and f5ba2de (test-lib: make "-x" work
with "--verbose-log", 2017-12-08), which were only needed to work
around bugs in the the previous --verbose-log implementation.
Replace it with a simple method for ensuring that we have valid TAP
both on stdout, and in any verbose output we write. When we detect
that we're running under "prove" we prefix all legitimate TAP
directives with "GIT_TEST_TEE_STARTED":
$ GIT_TEST_TEE_STARTED=1 ./t5547-push-quarantine.sh
GIT_TEST_TEE_STARTED ok 1 - create picky dest repo
GIT_TEST_TEE_STARTED ok 2 - accepted objects work
[...]
GIT_TEST_TEE_STARTED 1..6
Then, instead of piping the output to "tee -a" we pipe it to a helper
which first converts "ok" and other TAP syntax to e.g. "\ok", and then
strips that "GIT_TEST_TEE_STARTED " prefix from the start of the line,
resulting in:
$ HARNESS_ACTIVE=t ./t5547-push-quarantine.sh -v 2>&1 | grep -E '^.?ok'
ok 1 - create picky dest repo
\ok
ok 2 - accepted objects work
ok 3 - rejected objects are not installed
ok 4 - rejected objects are removed
ok 5 - push to repo path with path separator (colon)
ok 6 - updating a ref from quarantine is forbidden
We are thus guaranteed to have valid TAP syntax both on stdout, and in
the *.out files in the test-results/* directory. Validating the *.out
files isn't needed for now, but will be once we have anything that
wants to re-parse that output, e.g. to re-format it on-demand after
the tests have been run.
These changes would allow us to entirely get rid of the --verbose-log
special-case, as noted in 452320f it was only needed to deal with a
problem in the TAP output that's now gone away. We might think that
it's now redundant to using the -v run to prove itself:
prove <test> :: --verbose --tee
prove -v <test> :: --verbose --tee
However, since its introduction developers have also come to rely on
relied on --verbose-log for manually invoking the tests. So we're
keeping it.
Better yet, since we previous commits set us up to understand TAP
verbosity levels. The tests can now be run at differing levels of
verbosity, while ensuring that the full output gets logged to
test-results/*.out.
The -V option (or --verbose-log=1) will emit the same output as it did
before.
Supplying -V0 (or --verbose-log=0) will strip that output down to have
no comments at all, i.e. just TAP directives.
Supplying -VV (or --verbose-log=2) will include second-level comments,
-VVV (or --verbose-log=3) 3rd-level comments etc. See the comment
above "say_color_tap_comment()" introduced in preceding commits for
what levels of output are currently emitted.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
0 commit comments