Subject: Re: bailing out in tap tests nearly always a bad idea

From: Andres Freund <[email-masked]>
Date: Sun, 13 Feb 2022 15:47:19 -0800

Hi,

On 2022-02-13 18:32:59 -0500, Tom Lane wrote:
> Andres Freund <[email-masked]> 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.)

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. But it's still better than
BAIL_OUT. So I thought that putting the failure handling in a central routine
would allow us to make the exit nicer in a central place / at a later stage...

Greetings,

Andres Freund