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

[PATCH v4 3/5] test-lib: output a newline before "ok" under a TAP harness

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 24, 2010, 17:44 UTC
Message-ID
<1277401489-27885-4-git-send-email-avarab@gmail.com>
In-Reply-To
<1277401489-27885-1-git-send-email-avarab@gmail.com>

Some tests in the testsuite will emit a line that doesn't end with a newline, right before we're about to output "ok" or "not ok". This breaks the TAP output with "Tests out of sequence" errors since a TAP harness can't understand this:

    ok 1 - A test
    [some output here]ok 2 - Another test
    ok 3 - Yet another test

Work around it by emitting an empty line before we're about to say "ok" or "not ok", but only if we're running under --verbose and HARNESS_ACTIVE=1 is set, which'll only be the case when running under a harnesses like prove(1).

I think it's better to do this than fix each tests by adding `&& echo' everywhere. More tests might be added that break TAP in the future, and a human isn't going to look at the extra whitespace, since HARNESS_ACTIVE=1 always means a harness is reading it.

The tests that had issues were:
   t1007, t3410, t3413, t3409, t3414, t3415, t3416, t3412, t3404,
   t5407, t7402, t7003, t9001
With this workaround the entire test suite runs without errors under:
    prove -j 10 ./t[0-9]*.sh :: --verbose
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/test-lib.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7077210..ac496aa 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -371,6 +371,9 @@ test_run_ () {
 	eval >&3 2>&4 "$1"
 	eval_ret=$?
 	eval >&3 2>&4 "$test_cleanup"
+	if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
+		echo ""
+	fi
 	return 0
 }
 
-- 
1.7.1.251.g92a7
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 11 of 16 in “TAP support for Git”
  1. 0/5 TAP support for GitÆvar Arnfjörð Bjarmason, Jun 24, 2010
  2. 1/5 test-lib: Adjust output to be valid TAP formatÆvar Arnfjörð Bjarmason, Jun 24, 2010
  3. Jakub NarebskiJun 24, 2010
  4. Ævar Arnfjörð BjarmasonJun 24, 2010
  5. 1/5 test-lib: Adjust output to be valid TAP formatÆvar Arnfjörð Bjarmason, Jun 24, 2010
  6. Junio C HamanoJun 25, 2010
  7. Ævar Arnfjörð BjarmasonJun 25, 2010
  8. Junio C HamanoJun 25, 2010
  9. Ævar Arnfjörð BjarmasonJun 25, 2010
  10. 2/5 test-lib: Make the test_external_* functions TAP-awareÆvar Arnfjörð Bjarmason, Jun 24, 2010
  11. 3/5 test-lib: output a newline before "ok" under a TAP harnessÆvar Arnfjörð Bjarmason, Jun 24, 2010
  12. 4/5 tests: Skip tests in a way that makes sense under TAPÆvar Arnfjörð Bjarmason, Jun 24, 2010
  13. 5/5 tests: Say "pass" rather than "ok" on empty lines for TAPÆvar Arnfjörð Bjarmason, Jun 24, 2010
  14. t9700: Use Test::More->builder, not $Test::Builder::TestÆvar Arnfjörð Bjarmason, Jun 26, 2010
  15. t9700: Use Test::More->builder, not $Test::Builder::TestÆvar Arnfjörð Bjarmason, Jun 26, 2010
  16. Junio C HamanoJun 27, 2010

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.