aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2022-04-21 09:23:27 -0400
committerAndrew Dunstan <andrew@dunslane.net>2022-04-21 09:23:27 -0400
commit17bdba3ee69083e47069e9f26b4ee87d3d5dc3d5 (patch)
treeb2d04e506497d7c5e122cd197895f4823b41fd1d
parent5487585e376dd25d2cabc8a63a33c0286b3a199c (diff)
downloadpostgresql-17bdba3ee69083e47069e9f26b4ee87d3d5dc3d5.tar.gz
postgresql-17bdba3ee69083e47069e9f26b4ee87d3d5dc3d5.zip
Support new perl module namespace in stable branches
Commit b3b4d8e68a 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
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm16
-rw-r--r--src/test/perl/PostgreSQL/Test/Utils.pm44
-rw-r--r--src/test/perl/PostgresNode.pm14
-rw-r--r--src/test/perl/TestLib.pm39
4 files changed, 113 insertions, 0 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
new file mode 100644
index 00000000000..1e2fb50d6da
--- /dev/null
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -0,0 +1,16 @@
+
+# Copyright (c) 2022, PostgreSQL Global Development Group
+
+# allow use of release 15+ perl namespace in older branches
+# just 'use' the older module name.
+# See PostgresNode.pm for function implementations
+
+package PostgreSQL::Test::Cluster;
+
+use strict;
+use warnings;
+
+use PostgresNode;
+
+1;
+
diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
new file mode 100644
index 00000000000..455b6aff8e3
--- /dev/null
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -0,0 +1,44 @@
+# Copyright (c) 2022, PostgreSQL Global Development Group
+
+# allow use of release 15+ perl namespace in older branches
+# just 'use' the older module name.
+# We export the same names as the v15 module.
+# See TestLib.pm for alias assignment that makes this all work.
+
+package PostgreSQL::Test::Utils;
+
+use strict;
+use warnings;
+
+use Exporter 'import';
+
+use TestLib;
+
+our @EXPORT = qw(
+ generate_ascii_string
+ slurp_dir
+ slurp_file
+ append_to_file
+ check_mode_recursive
+ chmod_recursive
+ check_pg_config
+ system_or_bail
+ system_log
+ run_log
+ run_command
+
+ command_ok
+ command_fails
+ command_exit_is
+ program_help_ok
+ program_version_ok
+ program_options_handling_ok
+ command_like
+ command_like_safe
+ command_fails_like
+ command_checks_all
+
+ $windows_os
+);
+
+1;
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 7b2ec29bb74..e3b9b61ff35 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -2272,4 +2272,18 @@ sub corrupt_page_checksum
=cut
+# support release 15+ perl module namespace
+
+package PostgreSQL::Test::Cluster; ## no critic (ProhibitMultiplePackages)
+
+sub new
+{
+ shift; # remove class param from args
+ return PostgresNode->get_new_node(@_);
+}
+
+no warnings 'once';
+
+*get_free_port = *PostgresNode::get_free_port;
+
1;
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 6cd2c673ab1..cb315b9828d 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -621,4 +621,43 @@ sub command_checks_all
return;
}
+# support release 15+ perl module namespace
+
+package PostgreSQL::Test::Utils; ## no critic (ProhibitMultiplePackages)
+
+# we don't want to export anything here, but we want to support things called
+# via this package name explicitly.
+
+# use typeglobs to alias these functions and variables
+
+no warnings qw(once);
+
+*generate_ascii_string = *TestLib::generate_ascii_string;
+*slurp_dir = *TestLib::slurp_dir;
+*slurp_file = *TestLib::slurp_file;
+*append_to_file = *TestLib::append_to_file;
+*check_mode_recursive = *TestLib::check_mode_recursive;
+*chmod_recursive = *TestLib::chmod_recursive;
+*check_pg_config = *TestLib::check_pg_config;
+*system_or_bail = *TestLib::system_or_bail;
+*system_log = *TestLib::system_log;
+*run_log = *TestLib::run_log;
+*run_command = *TestLib::run_command;
+*command_ok = *TestLib::command_ok;
+*command_fails = *TestLib::command_fails;
+*command_exit_is = *TestLib::command_exit_is;
+*program_help_ok = *TestLib::program_help_ok;
+*program_version_ok = *TestLib::program_version_ok;
+*program_options_handling_ok = *TestLib::program_options_handling_ok;
+*command_like = *TestLib::command_like;
+*command_like_safe = *TestLib::command_like_safe;
+*command_fails_like = *TestLib::command_fails_like;
+*command_checks_all = *TestLib::command_checks_all;
+
+*windows_os = *TestLib::windows_os;
+*timeout_default = *TestLib::timeout_default;
+*tmp_check = *TestLib::tmp_check;
+*log_path = *TestLib::log_path;
+*test_logfile = *TestLib::test_log_file;
+
1;