mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	For PostgreSQL::Test compatibility, alias entire package symbol tables.
Remove the need to edit back-branch-specific code sites when back-patching the addition of a PostgreSQL::Test::Utils symbol. Replace per-symbol, incomplete alias lists. Give old and new package names the same EXPORT and EXPORT_OK semantics. Back-patch to v10 (all supported versions). Reviewed by Andrew Dunstan. Discussion: https://postgr.es/m/20220622072144.GD4167527@rfd.leadboat.com
This commit is contained in:
		| @@ -1,9 +1,9 @@ | |||||||
|  |  | ||||||
| # Copyright (c) 2022, PostgreSQL Global Development Group | # Copyright (c) 2022, PostgreSQL Global Development Group | ||||||
|  |  | ||||||
| # allow use of release 15+ perl namespace in older branches | # Allow use of release 15+ Perl package name in older branches, by giving that | ||||||
| # just 'use' the older module name. | # package the same symbol table as the older package.  See PostgresNode::new | ||||||
| # See PostgresNode.pm for function implementations | # for supporting heuristics. | ||||||
|  |  | ||||||
| package PostgreSQL::Test::Cluster; | package PostgreSQL::Test::Cluster; | ||||||
|  |  | ||||||
| @@ -11,5 +11,8 @@ use strict; | |||||||
| use warnings; | use warnings; | ||||||
|  |  | ||||||
| use PostgresNode; | use PostgresNode; | ||||||
|  | BEGIN { *PostgreSQL::Test::Cluster:: = \*PostgresNode::; } | ||||||
|  |  | ||||||
|  | use Exporter 'import'; | ||||||
|  |  | ||||||
| 1; | 1; | ||||||
|   | |||||||
| @@ -1,45 +1,16 @@ | |||||||
| # Copyright (c) 2022, PostgreSQL Global Development Group | # Copyright (c) 2022, PostgreSQL Global Development Group | ||||||
|  |  | ||||||
| # allow use of release 15+ perl namespace in older branches | # Allow use of release 15+ Perl package name in older branches, by giving that | ||||||
| # just 'use' the older module name. | # package the same symbol table as the older package. | ||||||
| # We export the same names as the v15 module. |  | ||||||
| # See TestLib.pm for alias assignment that makes this all work. |  | ||||||
|  |  | ||||||
| package PostgreSQL::Test::Utils; | package PostgreSQL::Test::Utils; | ||||||
|  |  | ||||||
| use strict; | use strict; | ||||||
| use warnings; | use warnings; | ||||||
|  |  | ||||||
|  | use TestLib; | ||||||
|  | BEGIN { *PostgreSQL::Test::Utils:: = \*TestLib::; } | ||||||
|  |  | ||||||
| use Exporter 'import'; | 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 |  | ||||||
|   pump_until |  | ||||||
|  |  | ||||||
|   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; | 1; | ||||||
|   | |||||||
| @@ -146,6 +146,17 @@ of finding port numbers, registering instances for cleanup, etc. | |||||||
| sub new | sub new | ||||||
| { | { | ||||||
| 	my ($class, $name, $pghost, $pgport) = @_; | 	my ($class, $name, $pghost, $pgport) = @_; | ||||||
|  |  | ||||||
|  | 	# Use release 15+ semantics when the arguments look like (node_name, | ||||||
|  | 	# %params).  We can't use $class to decide, because get_new_node() passes | ||||||
|  | 	# a v14- argument list regardless of the class.  $class might be an | ||||||
|  | 	# out-of-core subclass.  $class->isa('PostgresNode') returns true even for | ||||||
|  | 	# descendants of PostgreSQL::Test::Cluster, so it doesn't help. | ||||||
|  | 	return $class->get_new_node(@_[ 1 .. $#_ ]) | ||||||
|  | 	  if !$pghost | ||||||
|  | 	  or !$pgport | ||||||
|  | 	  or $pghost =~ /^[a-zA-Z0-9_]$/; | ||||||
|  |  | ||||||
| 	my $testname = basename($0); | 	my $testname = basename($0); | ||||||
| 	$testname =~ s/\.[^.]+$//; | 	$testname =~ s/\.[^.]+$//; | ||||||
| 	my $self = { | 	my $self = { | ||||||
| @@ -2307,18 +2318,4 @@ sub corrupt_page_checksum | |||||||
|  |  | ||||||
| =cut | =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; | 1; | ||||||
|   | |||||||
| @@ -652,43 +652,4 @@ sub command_checks_all | |||||||
| 	return; | 	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; | 1; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user