git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/8] running unit tests inside a test-lib script

From
Jeff King <peff@peff.net>
Date
Oct 27, 2026, 17:32 UTC
Message-ID
<20261027173205.GA97799@coredump.intra.peff.net>

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
Next: Jeff King
Message 1 of 9 in “running unit tests inside a test-lib script”
  1. 0/8 running unit tests inside a test-lib scriptJeff King, Oct 27, 2026
  2. 1/8 unit-tests: report the correct unexpected argumentJeff King, Oct 27, 2026
  3. 2/8 test-lib: drop unused test_external_has_tap variableJeff King, Oct 27, 2026
  4. 3/8 test-lib: stop inventing a JUnit testcase for empty suitesJeff King, Oct 27, 2026
  5. 4/8 test-lib: allow an external program to supply TAP outputJeff King, Oct 27, 2026
  6. 5/8 t: run clar unit tests through test-lib.shJeff King, Oct 27, 2026
  7. 6/8 t: drop redundant unit-test invocationsJeff King, Oct 27, 2026
  8. 7/8 test-tool: drop the run-command testsuite modeJeff King, Oct 27, 2026
  9. 8/8 test-lib: drop the shell JUnit XML reporting codeJeff King, Oct 27, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.