Skip to content

Commit 838a560

Browse files
author
Marina Polyakova
committed
PGPRO-5983: fix Perl tests due to changes in PostgreSQL 15devel
The standard PostgreSQL Perl modules for testing have been moved and some have been renamed. Try to maintain both old and new modules by checking if we can load new modules and loading the necessary modules at compile time. We cannot load these modules at runtime because they can have INIT blocks. Also use Perl's 'eval' function to call functions from these modules so we don't get compilation errors due to conditionally loading modules.
1 parent b5d2c58 commit 838a560

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

Diff for: t/001_basic.pl

+37-10
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,52 @@
66

77
use strict;
88
use warnings;
9-
use PostgresNode;
10-
use TestLib;
119
use Test::More;
1210

11+
my $pg_15_modules;
12+
13+
BEGIN
14+
{
15+
$pg_15_modules = eval
16+
{
17+
require PostgreSQL::Test::Cluster;
18+
require PostgreSQL::Test::Utils;
19+
return 1;
20+
};
21+
22+
unless (defined $pg_15_modules)
23+
{
24+
$pg_15_modules = 0;
25+
26+
require PostgresNode;
27+
require TestLib;
28+
}
29+
}
30+
1331
plan tests => 24;
1432

33+
note('PostgreSQL 15 modules are used: ' . ($pg_15_modules ? 'yes' : 'no'));
34+
1535
my $node;
1636
my $res;
1737
my $res_stdout;
1838
my $res_stderr;
1939

20-
# Initialize node
21-
# Older version of PostgresNode.pm use get_new_node function.
22-
# Newer use standard perl object constructor syntax
23-
if (PostgresNode->can('get_new_node')) {
24-
$node = get_new_node('node');
25-
} else {
26-
$node = PostgresNode->new("node");
27-
}
40+
# Create node.
41+
# Older versions of PostgreSQL modules use get_new_node function.
42+
# Newer use standard perl object constructor syntax.
43+
eval
44+
{
45+
if ($pg_15_modules)
46+
{
47+
$node = PostgreSQL::Test::Cluster->new("node");
48+
}
49+
else
50+
{
51+
$node = PostgresNode::get_new_node("node");
52+
}
53+
};
54+
2855
$node->init;
2956
$node->start;
3057

0 commit comments

Comments
 (0)