Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1c60a99

Browse files
committed
Support new perl module namespace in stable branches
Commit b3b4d8e moved our perl test modules to a better namespace structure, but this has made life hard for people wishing to backpatch improvements in the TAP tests. Here we alleviate much of that difficulty by implementing the new module names on top of the old modules, mostly by using a little perl typeglob aliasing magic, so that we don't have a dual maintenance burden. This should work both for the case where a new test is backpatched and the case where a fix to an existing test that uses the new namespace is backpatched. Reviewed by Michael Paquier Per complaint from Andres Freund Discussion: https://postgr.es/m/20220418141530.nfxtkohefvwnzncl@alap3.anarazel.de Applied to branches 10 through 14
1 parent 1272630 commit 1c60a99

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# Copyright (c) 2022, PostgreSQL Global Development Group
3+
4+
# allow use of release 15+ perl namespace in older branches
5+
# just 'use' the older module name.
6+
# See PostgresNode.pm for function implementations
7+
8+
package PostgreSQL::Test::Cluster;
9+
10+
use strict;
11+
use warnings;
12+
13+
use PostgresNode;
14+
15+
1;
16+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2022, PostgreSQL Global Development Group
2+
3+
# allow use of release 15+ perl namespace in older branches
4+
# just 'use' the older module name.
5+
# We export the same names as the v15 module.
6+
# See TestLib.pm for alias assignment that makes this all work.
7+
8+
package PostgreSQL::Test::Utils;
9+
10+
use strict;
11+
use warnings;
12+
13+
use Exporter 'import';
14+
15+
use TestLib;
16+
17+
our @EXPORT = qw(
18+
generate_ascii_string
19+
slurp_dir
20+
slurp_file
21+
append_to_file
22+
check_mode_recursive
23+
chmod_recursive
24+
check_pg_config
25+
system_or_bail
26+
system_log
27+
run_log
28+
run_command
29+
30+
command_ok
31+
command_fails
32+
command_exit_is
33+
program_help_ok
34+
program_version_ok
35+
program_options_handling_ok
36+
command_like
37+
command_like_safe
38+
command_fails_like
39+
command_checks_all
40+
41+
$windows_os
42+
$use_unix_sockets
43+
);
44+
45+
1;

src/test/perl/PostgresNode.pm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,4 +2381,18 @@ sub corrupt_page_checksum
23812381
23822382
=cut
23832383

2384+
# support release 15+ perl module namespace
2385+
2386+
package PostgreSQL::Test::Cluster; ## no critic (ProhibitMultiplePackages)
2387+
2388+
sub new
2389+
{
2390+
shift; # remove class param from args
2391+
return PostgresNode->get_new_node(@_);
2392+
}
2393+
2394+
no warnings 'once';
2395+
2396+
*get_free_port = *PostgresNode::get_free_port;
2397+
23842398
1;

src/test/perl/TestLib.pm

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,4 +900,44 @@ sub command_checks_all
900900
901901
=cut
902902

903+
# support release 15+ perl module namespace
904+
905+
package PostgreSQL::Test::Utils; ## no critic (ProhibitMultiplePackages)
906+
907+
# we don't want to export anything here, but we want to support things called
908+
# via this package name explicitly.
909+
910+
# use typeglobs to alias these functions and variables
911+
912+
no warnings qw(once);
913+
914+
*generate_ascii_string = *TestLib::generate_ascii_string;
915+
*slurp_dir = *TestLib::slurp_dir;
916+
*slurp_file = *TestLib::slurp_file;
917+
*append_to_file = *TestLib::append_to_file;
918+
*check_mode_recursive = *TestLib::check_mode_recursive;
919+
*chmod_recursive = *TestLib::chmod_recursive;
920+
*check_pg_config = *TestLib::check_pg_config;
921+
*system_or_bail = *TestLib::system_or_bail;
922+
*system_log = *TestLib::system_log;
923+
*run_log = *TestLib::run_log;
924+
*run_command = *TestLib::run_command;
925+
*command_ok = *TestLib::command_ok;
926+
*command_fails = *TestLib::command_fails;
927+
*command_exit_is = *TestLib::command_exit_is;
928+
*program_help_ok = *TestLib::program_help_ok;
929+
*program_version_ok = *TestLib::program_version_ok;
930+
*program_options_handling_ok = *TestLib::program_options_handling_ok;
931+
*command_like = *TestLib::command_like;
932+
*command_like_safe = *TestLib::command_like_safe;
933+
*command_fails_like = *TestLib::command_fails_like;
934+
*command_checks_all = *TestLib::command_checks_all;
935+
936+
*windows_os = *TestLib::windows_os;
937+
*use_unix_sockets = *TestLib::use_unix_sockets;
938+
*timeout_default = *TestLib::timeout_default;
939+
*tmp_check = *TestLib::tmp_check;
940+
*log_path = *TestLib::log_path;
941+
*test_logfile = *TestLib::test_log_file;
942+
903943
1;

0 commit comments

Comments
 (0)