diff options
author | Alvaro Herrera | 2023-03-09 11:02:18 +0000 |
---|---|---|
committer | Alvaro Herrera | 2023-03-09 11:02:18 +0000 |
commit | 590a075789b541d5c1a190031fdcf061355bcfbc (patch) | |
tree | ca21a88768fda460bae449bfb9202843df8799a5 | |
parent | d00a4ad1d56bbdbc032257803c0a97a583aec211 (diff) |
Avoid criticizable perl code
Using `require` / `->import` instead of `use` avoids the use of a
"stringy eval", making for cleaner code that we don't need to silence
perlcritic about.
Per Andrew Dunstan
Discussion: https://postgr.es/m/[email protected]
-rw-r--r-- | src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl index fbac405d0d1..7560439fec1 100644 --- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl +++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl @@ -9,16 +9,16 @@ use PostgreSQL::Test::Utils; use Test::More; # Use Test::Differences if installed, and select unified diff output. -# No decent way to select a context line count with this; -# we could use a sub ref to allow that. BEGIN { - #<<< protect next line from pgperltidy - if (!eval q{ use Test::Differences; unified_diff(); 1 }) ## no critic (ProhibitStringyEval) - #>>> - { - *eq_or_diff = \&is; - } + eval { + require Test::Differences; + Test::Differences->import; + unified_diff(); + }; + + # No dice -- fall back to 'is' + *eq_or_diff = \&is if $@; } my $node = PostgreSQL::Test::Cluster->new('main'); |