Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
Date: 2023-03-08 22:13:00
Message-ID: 7cd3bbbd-0216-4436-d571-8f80c9259a07@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)ntt(at)gmail(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2023-03-08 23:39:08 Re: lz4 --rm on Ubuntu 18.04 (Add LZ4 compression to pg_dump)
Previous Message Jeff Davis 2023-03-08 20:57:29 Re: pgsql: Allow tailoring of ICU locales with custom rules