Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available - Mailing list pgsql-committers

From Andrew Dunstan
Subject Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
Date
Msg-id 7cd3bbbd-0216-4436-d571-8f80c9259a07@dunslane.net
Whole thread Raw
In response to pgsql: 001_libpq_pipeline.pl: use Test::Differences if available  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-committers
On 2023-03-08 We 12:42, Alvaro Herrera wrote:
> 001_libpq_pipeline.pl: use Test::Differences if available
>
> When one of these tests fails to match the trace, this better shows what
> the problem is.
>
> Discussion: https://postgr.es/m/20220617183150.ilgokxp22mzywnhh@alvherre.pgsql
> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>


I don't think you need a stringy eval here, and they are something to be 
avoided in general. If you use `require` instead of `use` it should be 
unnecessary, and you can avoid all the perltidy ugliness.

something like this should do the trick:


    eval { require Test::Differences; Test::Differences->import; 
unified_diff; 1; };

    *eq_or_diff = \&is if $@;


I wonder if it's worth centralizing this.


cheers


andrew


-- 

Andrew Dunstan
EDB: https://www.enterprisedb.com




pgsql-committers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: pgsql: Allow tailoring of ICU locales with custom rules
Next
From: Michael Paquier
Date:
Subject: pgsql: doc: Add guidelines to generate coverage reports with meson