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

Re: [PATCH 2/2] test-lib.sh: use "Bail out!" syntax on bad SANITIZE=leak use

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 14, 2021, 17:25 UTC
Message-ID
<87v91zfrd7.fsf@evledraar.gmail.com>
In-Reply-To
<xmqqsfx3d0i3.fsf@gitster.g>
On Thu, Oct 14 2021, Junio C Hamano wrote:
Show 30 quoted lines
>> +BAIL_OUT () {
>> +	test $# -ne 1 && BUG "1 param"
>> +
>> +	# Do not change "Bail out! " string. It's part of TAP syntax:
>> +	# https://testanything.org/tap-specification.html
>> +	local bail_out="Bail out! "
>> +	local message="$1"
>> +
>> +	say_color error $bail_out "$message"
>> +	_error_exit
>> +}
>
> This looks like a good addition that can be used in similar cases
> later.  I'd assume that "Bail out!" early of a test sequence will
> mark the test suite as a failure as a whole, but I wonder if there
> is a similar "early abort" mechanism that would cause a success?  In
> some tests we do
>
> 	if .. some condition ..
> 	then
> 		test_done ;# because we cannot test the remainder
> 	fi
>
>         .. more tests ...
>
> and I've always thought the "done" an ugly hack.
>
> But that has nothing to do with the value of this change.
>
> Thanks.
That's:
    skip_all="reason"
    test_done
Which we could spell as:
    skip_all "reason"
Or whatever, if we wanted such a self-documenting helper.

There's no facility in TAP syntax to indicate in some special way that you'd like to skip all remaining things once your test is already running, the best you can do is just exit at that point.

I.e. the (very light amount of) special-ness (such as it is) is that if the very first line of the output is "1..0 skip [...]" progarms like "prove" will emit the skip summary as part of the output. See DIRECTIVES at https://testanything.org/tap-specification.html

Previous: Junio C Hamano
Message 6 of 6 in “test-lib.sh: add BAIL_OUT function, use it for SANITIZE=leak”
  1. 0/2 test-lib.sh: add BAIL_OUT function, use it for SANITIZE=leakÆvar Arnfjörð Bjarmason, Oct 14, 2021
  2. 1/2 test-lib.sh: de-duplicate error() teardown codeÆvar Arnfjörð Bjarmason, Oct 14, 2021
  3. Junio C HamanoOct 14, 2021
  4. 2/2 test-lib.sh: use "Bail out!" syntax on bad SANITIZE=leak useÆvar Arnfjörð Bjarmason, Oct 14, 2021
  5. Junio C HamanoOct 14, 2021
  6. Ævar Arnfjörð BjarmasonOct 14, 2021

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.