pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
Date: Thu, 9 Mar 2023 10:45:02 +0100
Message-ID: <20230309094502.heamw6al2vkjr4yw@alvherre.pgsql> (raw)
In-Reply-To: <7cd3bbbd-0216-4436-d571-8f80c9259a07@dunslane.net>

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")





view thread (4+ messages)  latest in thread

Message-ID: <20230309094502.heamw6al2vkjr4yw@alvherre.pgsql>
Permalink:  ../20230309094502.heamw6al2vkjr4yw@alvherre.pgsql/
Also on:    postgresql.org/message-id/20230309094502.heamw6al2vkjr4yw@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, andrew@dunslane.net
  Subject: Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
  In-Reply-To: <20230309094502.heamw6al2vkjr4yw@alvherre.pgsql>
  References: <7cd3bbbd-0216-4436-d571-8f80c9259a07@dunslane.net> <20230309094502.heamw6al2vkjr4yw@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox