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

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
Date: 2023-03-09 09:45:02
Message-ID: 20230309094502.heamw6al2vkjr4yw@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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")

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-03-09 10:28:08 pgsql: Add b6dfee28 to .git-blame-ignore-revs
Previous Message Alvaro Herrera 2023-03-09 09:34:12 Re: pgsql: Run pgindent on libpq's fe-auth.c, fe-auth-scram.c and fe-connec