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

From Alvaro Herrera
Subject Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
Date
Msg-id 20230309094502.heamw6al2vkjr4yw@alvherre.pgsql
Whole thread Raw
In response to Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-committers
On 2023-Mar-08, Andrew Dunstan wrote:

> 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 $@;

Hmm, I just grabbed the code from the Test::Differences manual, but I
agree that avoiding the stringy eval is better.  Let me try it out.

> I wonder if it's worth centralizing this.

I had a look around to see what might benefit from this.  At first I
thought the ugly pg_dump test would, but it doesn't because it uses
like/unlike, not 'is'.  Same with PostgreSQL::Test::Utils' command_like
and such: AFAICS they are all matching stdout on regexps.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"El que vive para el futuro es un iluso, y el que vive para el pasado,
un imbécil" (Luis Adler, "Los tripulantes de la noche")



pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgsql: Run pgindent on libpq's fe-auth.c, fe-auth-scram.c and fe-connec
Next
From: Michael Paquier
Date:
Subject: pgsql: Add b6dfee28 to .git-blame-ignore-revs