Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f484de

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 havebeen renamed. Try to maintain both old and new modules by exporting theenviromental variable VERSION_NUM and conditionally loading the required modulesat compile time. We cannot load these modules at runtime because they can haveINIT blocks.Also use Perl's 'eval' function to call functions from these modules so we don'tget compilation errors due to conditionally loading modules.The enviromental variable PG_15_PERL_MUDULES is for running tests on Windowsusing MSVC because I'm not sure if it would be better to try to find and exportthe variable VERSION_NUM in vcregress.pl.. It also seems to be easier to justexport the variable VERSION_NUM in Makefile on Linux instead of creating aversion check using shell commands..
1 parentb5d2c58 commit3f484de

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

‎Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ top_builddir = ../..
2020
include$(top_builddir)/src/Makefile.global
2121
include$(top_srcdir)/contrib/contrib-global.mk
2222
endif
23+
24+
# Use the enviromental variable VERSION_NUM to specify which PostgreSQL Perl
25+
# modules to load into Perl tests at compile time (we cannot use the function
26+
# 'require' to load them at runtime because they can have INIT blocks).
27+
exportVERSION_NUM

‎t/001_basic.pl‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,45 @@
66

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

13-
plantests=> 24;
11+
# We cannot use the function 'require' to conditionally load PostgreSQL modules
12+
# at runtime because they can have INIT blocks.
13+
14+
use constantPG_15_PERL_MUDULES=>
15+
((defined$ENV{VERSION_NUM}and$ENV{VERSION_NUM} >= 150000)or
16+
defined$ENV{PG_15_PERL_MUDULES});
17+
18+
useif PG_15_PERL_MUDULES,"PostgreSQL::Test::Cluster";
19+
useif PG_15_PERL_MUDULES,"PostgreSQL::Test::Utils";
20+
21+
useif (not PG_15_PERL_MUDULES),"PostgresNode";
22+
useif (not PG_15_PERL_MUDULES),"TestLib";
23+
24+
plantests=> 25;
1425

1526
my$node;
1627
my$res;
1728
my$res_stdout;
1829
my$res_stderr;
1930

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-
}
31+
# Create node.
32+
# Older versions of PostgreSQL modules use get_new_node function.
33+
# Newer use standard perl object constructor syntax.
34+
$res =eval
35+
{
36+
if (PG_15_PERL_MUDULES)
37+
{
38+
$node = PostgreSQL::Test::Cluster->new("node");
39+
}
40+
else
41+
{
42+
$node = get_new_node("node");
43+
}
44+
return 1;
45+
};
46+
is($res, 1,'the node is created successfully');
47+
2848
$node->init;
2949
$node->start;
3050

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp