Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 0/8] running unit tests inside a test-lib script
Date: Tue, 27 Oct 2026 13:32:05 -0400	[thread overview]
Message-ID: <20261027173205.GA97799@coredump.intra.peff.net> (raw)

I saw a unit-test failure in CI a while back, and much to my annoyance
it was quite hard to debug, because we don't report the unit-test output
at all!

The problem is that we feed the unit-test binary to prove, which eats the
TAP output it produces. Normal tests get around this by using
--verbose-log (and then CI dumps the log). But the unit-test script
silently ignores that option, and you get no feedback at all about which
test failed.

We could fix that, obviously, but I think it's a symptom of a larger
problem: we don't do the usual setup things that test-lib.sh does.
Another example I found in the real world is that we skip some
environment setup, like LSAN_OPTIONS, leading to worse output for some
leaks. I'd guess there are other cases, as well.

So the real goal of this series is patch 5, which just lets us wrap the
unit-test binary in a regular t0001-unit-tests.sh script. Patch 4 is the
test-lib.sh tweaks needed for this.

And naturally, the whole thing turned up a few bugs, which are fixed in
patches 1-3. But it also turned up a number of cleanup possibilities.
The diffstat is very satisfying, but note the final two which I've
marked as RFC.

This would also avoid the need for the unit-tests to ignore test-lib
options, like the patches we saw recently in:

  https://lore.kernel.org/git/20261026-ks-unit-tests-ignore-long-tests-v2-0-fdbbefbd19fb@gmail.com/

I didn't clean up the existing ignored ones here, but I think it would
probably be reasonable to do so.

  [1/8]: unit-tests: report the correct unexpected argument
  [2/8]: test-lib: drop unused test_external_has_tap variable
  [3/8]: test-lib: stop inventing a JUnit testcase for empty suites
  [4/8]: test-lib: allow an external program to supply TAP output
  [5/8]: t: run clar unit tests through test-lib.sh
  [6/8]: t: drop redundant unit-test invocations
  [7/8]: test-tool: drop the run-command testsuite mode
  [8/8]: test-lib: drop the shell JUnit XML reporting code

 Makefile                    |   1 -
 ci/run-test-slice.sh        |   5 --
 t/Makefile                  |  12 +--
 t/helper/meson.build        |   1 -
 t/helper/test-run-command.c | 173 ------------------------------------
 t/helper/test-tool.c        |   1 -
 t/helper/test-tool.h        |   1 -
 t/helper/test-xml-encode.c  |  80 -----------------
 t/meson.build               |   4 +-
 t/run-test.sh               |  18 ----
 t/t0011-unit-tests.sh       |  20 +++++
 t/test-lib-junit.sh         | 132 ---------------------------
 t/test-lib.sh               |  16 ++--
 t/unit-tests/unit-test.c    |   2 +-
 14 files changed, 33 insertions(+), 433 deletions(-)
 delete mode 100644 t/helper/test-xml-encode.c
 delete mode 100755 t/run-test.sh
 create mode 100755 t/t0011-unit-tests.sh
 delete mode 100644 t/test-lib-junit.sh

             reply	other threads:[~2026-10-27 17:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 17:32 Jeff King [this message]
2026-10-27 17:32 ` [PATCH 1/8] unit-tests: report the correct unexpected argument Jeff King
2026-10-27 17:32 ` [PATCH 2/8] test-lib: drop unused test_external_has_tap variable Jeff King
2026-10-27 17:35 ` [PATCH 3/8] test-lib: stop inventing a JUnit testcase for empty suites Jeff King
2026-10-27 17:36 ` [PATCH 4/8] test-lib: allow an external program to supply TAP output Jeff King
2026-10-27 17:38 ` [PATCH 5/8] t: run clar unit tests through test-lib.sh Jeff King
2026-10-27 17:40 ` [PATCH 6/8] t: drop redundant unit-test invocations Jeff King
2026-10-27 17:41 ` [RFC/PATCH 7/8] test-tool: drop the run-command testsuite mode Jeff King
2026-10-27 17:42 ` [RFC/PATCH 8/8] test-lib: drop the shell JUnit XML reporting code Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027173205.GA97799@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox