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

[PATCH] t4018: drop "debugging" cat from hunk-header tests

From
Jeff King <peff@peff.net>
Date
Jan 16, 2020, 18:34 UTC
Message-ID
<20200116183423.GA3011203@coredump.intra.peff.net>
In-Reply-To
<20200116175138.GA691238@coredump.intra.peff.net>
We run a series of hunk-header tests in a loop, and each one does this:
  test_when_finished 'cat actual' &&      # for debugging only

This is pretty pointless. When the test succeeds, we waste time running a useless cat process. If you're debugging a failure with "-i", then we won't run the when-finished part at all. So it helps only if you're running with something like "--verbose-log".

Since we expect the tests to succeed most of the time, a better way to do this would be a helper that checks the output and dumps "actual" only when it fails. But it's probably not even worth the effort, as anyone debugging a failure could just run with "-i" and investigate the "actual" file themselves.

Signed-off-by: Jeff King <peff@peff.net>
---
Just noticed this when working with t4018 on an unrelated problem.

I could be convinced otherwise on the final paragraph, but I think it would only be worth it if we added a general test_grep() helper and used it in more places.

 t/t4018-diff-funcname.sh | 1 -
 1 file changed, 1 deletion(-)
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index c0f4839543..02255a08bf 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -106,7 +106,6 @@ do
 		result=success
 	fi
 	test_expect_$result "hunk header: $i" "
-		test_when_finished 'cat actual' &&	# for debugging only
 		git diff -U1 $i >actual &&
 		grep '@@ .* @@.*RIGHT' actual
 	"
-- 
2.25.0.318.gee4019ba55
Previous: Jeff KingNext: Jonathan Nieder
Message 2 of 7 in “Makefile: use compat regex with SANITIZE=address”
  1. Makefile: use compat regex with SANITIZE=addressJeff King, Jan 16, 2020
  2. t4018: drop "debugging" cat from hunk-header testsJeff King, Jan 16, 2020
  3. Jonathan NiederJan 16, 2020
  4. Junio C HamanoJan 17, 2020
  5. Jeff KingJan 17, 2020
  6. brian m. carlsonJan 17, 2020
  7. Jeff KingJan 18, 2020

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.