Re: bailing out in tap tests nearly always a bad idea - Mailing list pgsql-hackers

From Dagfinn Ilmari Mannsåker
Subject Re: bailing out in tap tests nearly always a bad idea
Date
Msg-id 871r05zb05.fsf@wibble.ilmari.org
Whole thread Raw
In response to Re: bailing out in tap tests nearly always a bad idea  (Andres Freund <andres@anarazel.de>)
Responses Re: bailing out in tap tests nearly always a bad idea
List pgsql-hackers
Andres Freund <andres@anarazel.de> writes:

> Hi,
>
> On 2022-02-13 18:32:59 -0500, Tom Lane wrote:
>> Andres Freund <andres@anarazel.de> writes:
>> > Best with a
>> > central function signalling fatal error, rather than individual uses of die
>> > or such.
>>
>> Huh, doesn't Test::More already provide a sane way to do this?
>
> I looked, and didn't see anything. But I'm not a perl person, so I might just
> have missed something.
>
>> If not, why isn't die() good enough?  (I don't think you can
>> realistically expect to prohibit die() anywhere in the TAP tests.)

die()-ing is the correct way to abort a single test script.

> The output of dying isn't great either:
>
> t/000_fail.pl ........................ Dubious, test returned 25 (wstat 6400, 0x1900)
> No subtests run
>
> it'd be nicer if that that showed the actual reason for failing, rather than
> the unhelpful "Dubious, test returned" stuff.

It does output the die() message, but it's on stderr, while the harness
output is on stdout, so redirections might interfere.

$ echo 'use Test::More; die "aieee";' > t/die-immediately.t
$ echo 'use Test::More; pass "yay"; die "aieee";' > t/die-after-success.t
$ prove --quiet 
t/die-after-success.t .. 1/? aieee at t/die-after-success.t line 1.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 1.
t/die-after-success.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
All 1 subtests passed
t/die-immediately.t .... aieee at t/die-immediately.t line 1.
t/die-immediately.t .... Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
  
> Greetings,
>
> Andres Freund

- ilmari



pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints
Next
From: Dilip Kumar
Date:
Subject: Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints