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

Re: [PATCH v2 3/6] test-lib: verbose mode for only tests matching a pattern

From
Jeff King <peff@peff.net>
Date
Jun 18, 2013, 05:37 UTC
Message-ID
<20130618053710.GB5916@sigill.intra.peff.net>
In-Reply-To
<8739d3ba5947c60d402030fc35d47115e7a51b0f.1371460265.git.trast@inf.ethz.ch>
On Mon, Jun 17, 2013 at 11:18:48AM +0200, Thomas Rast wrote:
Show 5 quoted lines
> As suggested by Jeff King, this takes care to wrap the entire test_expect_*
> block, but nothing else, in the verbose toggling.  To that end we use
> a new pair of hook functions.  The placement is a bit weird because we
> need to wait until the beginning of test_skip for $test_count to be
> incremented.

I guess it is not surprising because I suggested it, but I find the new setup/teardown logic easier to follow than the old toggle. The weird placement did throw me for a minute while reading the patch. I wonder if it is worth pulling the increment out of test_skip, to have something like this in test_expect_*:

  test_start ;# increment number, run setup hooks
  if ! test_skip
  then
    ...
  fi
  test_finish ;# teardown hooks

Then it is a bit easier to see that each start has a finish (whereas in the current version, the setups in test_skip are matched by individual teardowns in each caller). I did not look too hard at it, though, so I wouldn't be surprised if there is some other hidden order dependency that makes that not work. :)

Show 11 quoted lines
> +# Called from test_skip after it has incremented $test_count.  This
> +# means it runs before any test-specific code and output.
> +test_setup_hook_ () {
> +	maybe_setup_verbose
> +}
> +
> +# Called at the end of test_expect_*.  This means it runs after all
> +# test-specific code and output.
> +test_teardown_hook_ () {
> +	maybe_teardown_verbose
> +}
So these do your verbose setup/teardown. Makes sense.
But then what is this hunk doing:
Show 13 quoted lines
>  test_eval_ () {
>  	# This is a separate function because some tests use
>  	# "return" to end a test_expect_success block early.
> @@ -358,9 +399,7 @@ test_run_ () {
>  
>  	if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
>  	then
> -		setup_malloc_check
>  		test_eval_ "$test_cleanup"
> -		teardown_malloc_check
>  	fi
>  	if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
>  	then

At first I thought these should go into your setup/teardown hooks, but I don't think so. They are made redundant by patch 1/6, which wraps all of test_eval with malloc setup/teardown, aren't they? Should this hunk be in patch 1?

-Peff
Previous: Thomas RastNext: Thomas Rast
Message 29 of 44 in “--valgrind improvements”
  1. 0/6 --valgrind improvementsThomas Rast, May 16, 2013
  2. 1/6 test-lib: enable MALLOC_* for the actual testsThomas Rast, May 16, 2013
  3. Elia PintoMay 16, 2013
  4. Junio C HamanoMay 16, 2013
  5. 2/6 test-lib: refactor $GIT_SKIP_TESTS matchingThomas Rast, May 16, 2013
  6. Johannes SixtMay 17, 2013
  7. Thomas RastMay 17, 2013
  8. Junio C HamanoMay 17, 2013
  9. Thomas RastMay 17, 2013
  10. Junio C HamanoMay 17, 2013
  11. Johannes SixtMay 17, 2013
  12. 3/6 test-lib: verbose mode for only tests matching a patternThomas Rast, May 16, 2013
  13. Jeff KingMay 29, 2013
  14. Jeff KingMay 29, 2013
  15. Junio C HamanoMay 29, 2013
  16. 4/6 test-lib: valgrind for only tests matching a patternThomas Rast, May 16, 2013
  17. 5/6 test-lib: allow prefixing a custom string before "ok N" etc.Thomas Rast, May 16, 2013
  18. Phil HordMay 16, 2013
  19. Thomas RastMay 17, 2013
  20. Phil HordMay 17, 2013
  21. 6/6 test-lib: support running tests under valgrind in parallelThomas Rast, May 16, 2013
  22. Jeff KingMay 29, 2013
  23. 0/6 --valgrind improvementsThomas Rast, Jun 17, 2013
  24. 1/6 test-lib: enable MALLOC_* for the actual testsThomas Rast, Jun 17, 2013
  25. 2/6 test-lib: refactor $GIT_SKIP_TESTS matchingThomas Rast, Jun 17, 2013
  26. Johannes SixtJun 18, 2013
  27. Thomas RastJun 18, 2013
  28. 3/6 test-lib: verbose mode for only tests matching a patternThomas Rast, Jun 17, 2013
  29. Jeff KingJun 18, 2013
  30. Thomas RastJun 18, 2013
  31. 4/6 test-lib: valgrind for only tests matching a patternThomas Rast, Jun 17, 2013
  32. 5/6 test-lib: allow prefixing a custom string before "ok N" etc.Thomas Rast, Jun 17, 2013
  33. 6/6 test-lib: support running tests under valgrind in parallelThomas Rast, Jun 17, 2013
  34. Jeff KingJun 18, 2013
  35. 0/8 --valgrind improvementsThomas Rast, Jun 18, 2013
  36. 1/8 test-lib: enable MALLOC_* for the actual testsThomas Rast, Jun 18, 2013
  37. 2/8 test-lib: refactor $GIT_SKIP_TESTS matchingThomas Rast, Jun 18, 2013
  38. 3/8 test-lib: rearrange start/end of test_expect_* and test_skipThomas Rast, Jun 18, 2013
  39. Junio C HamanoJun 18, 2013
  40. 4/8 test-lib: self-test that --verbose worksThomas Rast, Jun 18, 2013
  41. 5/8 test-lib: verbose mode for only tests matching a patternThomas Rast, Jun 18, 2013
  42. 6/8 test-lib: valgrind for only tests matching a patternThomas Rast, Jun 18, 2013
  43. 7/8 test-lib: allow prefixing a custom string before "ok N" etc.Thomas Rast, Jun 18, 2013
  44. 8/8 test-lib: support running tests under valgrind in parallelThomas Rast, Jun 18, 2013

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.