Re: More business with $Test::Builder::Level in the TAP tests - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: More business with $Test::Builder::Level in the TAP tests
Date
Msg-id F62445C7-F83B-4909-8152-1962F2841528@yesql.se
Whole thread Raw
In response to Re: More business with $Test::Builder::Level in the TAP tests  (Michael Paquier <michael@paquier.xyz>)
Responses Re: More business with $Test::Builder::Level in the TAP tests
List pgsql-hackers
> On 7 Oct 2021, at 03:53, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Oct 06, 2021 at 07:33:22AM -0400, Andrew Dunstan wrote:
>> We should probably state a requirement for this somewhere. Maybe in
>> src/test/perl/README. AIUI, the general rule is that any subroutine that
>> directly or indirectly calls ok() and friends should increase the level.
>> Such subroutines that don't increase it should probably contain a
>> comment stating why, so we can know in future that it's not just an
>> oversight.
>
> That makes sense.  How about something like that after the part about
> Test::More::like and qr// in the section about writing tests?  Here it
> is:
> +Test::Builder::Level controls how far up in the call stack a test will look
> +at when reporting a failure.  This should be incremented by any subroutine
> +calling test routines from Test::More, like ok() or is():
> +
> +    local $Test::Builder::Level = $Test::Builder::Level + 1;

LGTM.  Maybe it should be added that it *must* be called before any Test::More
function is called, it's sort of self-explanatory but not everyone writing TAP
tests will be deeply familiar with Perl.

--
Daniel Gustafsson        https://vmware.com/




pgsql-hackers by date:

Previous
From: bt21masumurak
Date:
Subject: Improve the HINT message of the ALTER command for postgres_fdw
Next
From: Fabrice Chapuis
Date:
Subject: Re: Logical replication timeout problem