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

[PATCH 4/8] test-lib: allow an external program to supply TAP output

From
Jeff King <peff@peff.net>
Date
Oct 27, 2026, 17:36 UTC
Message-ID
<20261027173645.GD136740@coredump.intra.peff.net>
In-Reply-To
<20261027173205.GA97799@coredump.intra.peff.net>

A program which produces its own TAP output can't use test-lib.sh, because our TAP header and test counts conflict.

We used to support this with test_external, but dropped it in 5beca49a0b (test-lib: simplify by removing test_external, 2022-07-28). That interface let you mix shell tests with external TAP, which required special handling for the test counts. But we can bring back a much simpler variant: tell test-lib.sh up front that it will be a thin wrapper for an external TAP generator, and let it stay out of the way.

Now you might ask what is the point of using test-lib.sh at all if it's not going to generate any output. And the point is: it does other useful setup, like handling logging, setting certain environment variables, and so on. The next commit will wrap the clar unit-tests which will bring some real-world benefits.

The only changes we need here are avoiding the TAP header and the plan count. Note that if we skip the whole script via GIT_SKIP_TESTS, though, we still have to emit a count (since we wouldn't run the external command at all).

Signed-off-by: Jeff King <peff@peff.net>
---
 t/test-lib.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 3d001b91da..3754db0ea7 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1277,8 +1277,11 @@ test_done () {
 
 		# Maybe print SKIP message
 		test -z "$skip_all" || skip_all="# SKIP $skip_all"
-		case "$test_count" in
-		0)
+		case "$test_external,$skip_all,$test_count" in
+		t,,*)
+			: nothing
+			;;
+		*,*,0)
 			say "1..$test_count${skip_all:+ $skip_all}"
 			;;
 		*)
@@ -1534,7 +1537,7 @@ then
 	BAIL_OUT 'You need to build test-tool; Run "make t/helper/test-tool" in the source (toplevel) directory'
 fi
 
-if test -n "$HARNESS_ACTIVE"
+if test -n "$HARNESS_ACTIVE" && test -z "$test_external"
 then
 	say "TAP version 13"
 	say "pragma +strict"
-- 
2.56.0.559.g7c1a1d8168
Previous: Jeff KingNext: Jeff King
Message 5 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.