Re: Show backtrace when tap tests fail

From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org, Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: Show backtrace when tap tests fail
Date: 2017-09-19 20:37:26
Message-ID: d8jzi9qe86x.fsf@dalvik.ping.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com> writes:

> On 09/19/2017 01:31 PM, Andres Freund wrote:
>> Hi,
>>
>> I've had a couple cases where tap tests died, and I couldn't easily see
>> where / why. For development of a new test I found it useful to show
>> backtraces in that case - just adding a
>> use Carp::Always;
>> at the start of the relevant module did the trick.
>>
>> I'm wondering if we shouldn't always do so if the module is
>> installed. I.e. have PostgresNode or something do something like

I think TestLib would be a better place, since PostgresNode uses TestLib
and there are some tests that use TestLib but notf PostgresNode.

>> # Include module showing backtraces upon failures. As it's a
>> non-standard module, don't fail if not installed.
>> eval { use Carp::Always; }
>>
>> Comments?
>
> Or maybe Devel::Confess ?

Devel::Confess is more thorough, so +1 on that.

> In an eval you need a 'require' rather than a 'use', AFAIK.

Yes, because 'use' happens as soon as the statement is parsed at compile
time, long before the eval { } gets executed. Devel::Confess does its
setup in the 'import' method (called implicitly by 'use'), so we'd need:

eval { require Devel::Confess; Devel::Confess->import };

--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2017-09-19 20:39:31 Re: Re: issue: record or row variable cannot be part of multiple-item INTO list
Previous Message Heikki Linnakangas 2017-09-19 20:32:58 Re: SCRAM in the PG 10 release notes