pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
4+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2023-03-09 590a075789  Avoid criticizable perl code
* pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
@ 2023-03-08 17:42  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Alvaro Herrera @ 2023-03-08 17:42 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/87e4f24d82939ef532b68f37fc66e6a48cff2cd9

Modified Files
--------------
src/test/modules/libpq_pipeline/README                  |  3 +++
src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl | 15 ++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
@ 2023-03-08 22:13  Andrew Dunstan <andrew@dunslane.net>
  parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Andrew Dunstan @ 2023-03-08 22:13 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers@lists.postgresql.org


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






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
@ 2023-03-09 09:45  Alvaro Herrera <alvherre@alvh.no-ip.org>
  parent: Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 1 reply; 4+ messages in thread

From: Alvaro Herrera @ 2023-03-09 09:45 UTC (permalink / raw)
  To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available
@ 2023-03-09 11:03  Alvaro Herrera <alvherre@alvh.no-ip.org>
  parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Alvaro Herrera @ 2023-03-09 11:03 UTC (permalink / raw)
  To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers@lists.postgresql.org

On 2023-Mar-09, Alvaro Herrera wrote:

> On 2023-Mar-08, Andrew Dunstan wrote:
> 
> > 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.

It seemed to work fine for me, so pushed.  Thanks for the suggestion.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2023-03-09 11:03 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 17:42 pgsql: 001_libpq_pipeline.pl: use Test::Differences if available Alvaro Herrera <alvherre@alvh.no-ip.org>
2023-03-08 22:13 ` Andrew Dunstan <andrew@dunslane.net>
2023-03-09 09:45   ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2023-03-09 11:03     ` Alvaro Herrera <alvherre@alvh.no-ip.org>

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