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

Re: [PATCH 03/11] test-lib: introduce 'test_atexit'

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2019, 01:50 UTC
Message-ID
<xmqqwokx6jdo.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190314174024.GH28939@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 11 quoted lines
>> but it even skips when there is no point doing the
>> test_eval_ of the "accumulated" scriptlet when it is empty.
>
> But this is not, because $test_cleanup is initialized to this special
> value and it can never be empty, and indeed 'test_eval_' uses this
> condition:
>
>   if test -z "$immediate" || test $eval_ret = 0 ||
>      test -n "$expecting_failure" && test "$test_cleanup" != ":"
>
> and it never checks $test_cleanup's emptiness.

Yeah, I used "empty" not in the literal sense; I know why the "empty in spirit" setting is a single colon for $test_cleanup.

I just did not realize that this new variable was using that exact pattern and using ":" as the empty in spirit, and that was where my fuzzy wordibng came from.

So in short, I misread the code, and part of that is because I was misled by the comment:

> +	# This condition and resetting 'test_atexit_cleanup' below makes
> +	# sure that the registered cleanup commands are run only once.
> +	test : != "$test_atexit_cleanup" || return 0

It over-stresses the "run only once", but the true value of this is that it avoids running an "empty in spirit" clean-up sequence.

The avoidance of double execution merely takes advantage of this implementation detail by "resetting" the variable is better explained where the "resetting" happens (i.e. "we reset the variable to the 'no-command' state, as we've run all of them here, but just before the process finally exits, the helper will be called and we do not want to run these commands again when it happens").

Thanks.
Previous: SZEDER GáborNext: SZEDER Gábor
Message 11 of 21 in “tests: introduce 'test_atexit'”
  1. 00/11 tests: introduce 'test_atexit'SZEDER Gábor, Mar 13, 2019
  2. 01/11 test-lib: fix interrupt handling with 'dash' and '--verbose-log -x'SZEDER Gábor, Mar 13, 2019
  3. Junio C HamanoMar 14, 2019
  4. SZEDER GáborMar 14, 2019
  5. 02/11 t/lib-git-daemon: make sure to kill the 'git-daemon' processSZEDER Gábor, Mar 13, 2019
  6. Junio C HamanoMar 14, 2019
  7. 04/11 git-daemon: use 'test_atexit` to stop 'git-daemon'SZEDER Gábor, Mar 13, 2019
  8. 03/11 test-lib: introduce 'test_atexit'SZEDER Gábor, Mar 13, 2019
  9. Junio C HamanoMar 14, 2019
  10. SZEDER GáborMar 14, 2019
  11. Junio C HamanoMar 18, 2019
  12. 05/11 tests: use 'test_atexit' to stop httpdSZEDER Gábor, Mar 13, 2019
  13. Junio C HamanoMar 14, 2019
  14. Junio C HamanoMar 14, 2019
  15. SZEDER GáborMar 14, 2019
  16. 06/11 t0301-credential-cache: use 'test_atexit' to stop the credentials helperSZEDER Gábor, Mar 13, 2019
  17. 07/11 git p4 test: use 'test_atexit' to kill p4d and the watchdog processSZEDER Gábor, Mar 13, 2019
  18. 10/11 git p4 test: disable '-x' tracing in the p4d watchdog loopSZEDER Gábor, Mar 13, 2019
  19. 09/11 git p4 test: simplify timeout handlingSZEDER Gábor, Mar 13, 2019
  20. 11/11 t9811-git-p4-label-import: fix pipeline negationSZEDER Gábor, Mar 13, 2019
  21. 08/11 git p4 test: clean up the p4d cleanup functionsSZEDER Gábor, Mar 13, 2019

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.