"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
[rfc] regress: add line number to failure output
To:
Game of Trees <gameoftrees@openbsd.org>
Date:
Tue, 14 Feb 2023 19:19:28 +1100

Download raw body.

Thread
I made adjusting regress for the new fetch behaviour change more
difficult than necessary because of a copypasta error where the reported
failure returned a bogus test function. Silly error on my part but to
figure out the cause of the failure I added $LINENO to the output such
that we get:

  test failed [1823]; leaving test data in /tmp/got-test-fetch_honor_wt_conf_bflag-OwBuXVET

This was just quicker than looking at the test data saved in this case
because the tests were very similar.

And even in the case where the correct function is reported, the line
number will make it easier to pinpoint the problem in the larger test
routines.

That said, the proposed diff is large (20 KLOC); it's a simple s/xyz/abc
so that $LINENO is passed to each test_done() failure call; for example:

@@ -22,7 +22,7 @@ test_add_basic() {
 	got checkout $testroot/repo $testroot/wt > /dev/null
 	ret=$?
 	if [ $ret -ne 0 ]; then
-		test_done "$testroot" "$ret"
+		test_done "$testroot" "$ret" $LINENO
 		return 1
 	fi
 

and this small change to test_done() in common.sh:

blob - 96339d43615d5d8fad7e4a300f64c7db2dc9cea8
file + regress/cmdline/common.sh
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
@@ -256,6 +256,7 @@ test_done()
 {
 	local testroot="$1"
 	local result="$2"
+	local lineno=$3
 	if [ "$result" = "0" ]; then
 		test_cleanup "$testroot" || return 1
 		if [ -z "$GOT_TEST_QUIET" ]; then
@@ -266,6 +267,6 @@ test_done()
 		echo "$result"
 		test_cleanup "$testroot" || return 1
 	else
-		echo "test failed; leaving test data in $testroot"
+		echo "test failed [$lineno]; leaving test data in $testroot"
 	fi
 }

It's too large to paste inline but it's here: http://yy.jamsek.net/ze7f

This is just a thought; it actually helped recently so I figured I'd
share and RFC. Thanks!

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68