Skip to content

Commit 87e4f24

Browse files
committed
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>
1 parent 30a53b7 commit 87e4f24

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/test/modules/libpq_pipeline/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
Test programs and libraries for libpq
2+
3+
If you have Test::Differences installed, any differences in the trace files
4+
are displayed in a format that's easier to read than the standard format.
25
=====================================
36

47
This module was developed to test libpq's "pipeline" mode, but it can

src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
use PostgreSQL::Test::Utils;
99
use Test::More;
1010

11+
# Use Test::Differences if installed, and select unified diff output.
12+
# No decent way to select a context line count with this;
13+
# we could use a sub ref to allow that.
14+
BEGIN
15+
{
16+
#<<< protect next line from pgperltidy
17+
if (!eval q{ use Test::Differences; unified_diff(); 1 }) ## no critic (ProhibitStringyEval)
18+
#>>>
19+
{
20+
*eq_or_diff = \&is;
21+
}
22+
}
23+
1124
my $node = PostgreSQL::Test::Cluster->new('main');
1225
$node->init;
1326
$node->start;
@@ -55,7 +68,7 @@
5568
$result = slurp_file_eval($traceout);
5669
next unless $result ne "";
5770

58-
is($result, $expected, "$testname trace match");
71+
eq_or_diff($result, $expected, "$testname trace match");
5972
}
6073
}
6174

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy