Here's a couple of small patches I came up with while doing some related work on TAP tests.
The first makes the argument for $node->config_data() optional. If it's not supplied, pg_config is called without an argument and the whole result is returned. Currently, if you try that you get back a nasty and cryptic error. The second changes the new GUCs TAP test to check against the installed postgresql.conf.sample rather than the one in the original source location. There are probably arguments both ways, but if we ever decided to postprocess the file before installation, this would do the right thing. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
From 4a828045aa3f4d85c012deda9bd953025af1291d Mon Sep 17 00:00:00 2001 From: Andrew Dunstan <and...@dunslane.net> Date: Mon, 13 Jun 2022 18:16:33 -0400 Subject: [PATCH 1/2] Allow option argument for config_data method to be missing If the argument is missing the current code gets a nasty and cryptic error message from IPC::Run. Instead we allow the argument to be missing and in this case all the config lines are returned to the caller. --- src/test/perl/PostgreSQL/Test/Cluster.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm index c8c7bc5045..d6c485545b 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -348,18 +348,18 @@ sub pg_version =item $node->config_data($option) Return a string holding configuration data from pg_config, with $option -being the option switch used with the pg_config command. +(if supplied) being the option switch used with the pg_config command. =cut sub config_data { - my ($self, $option) = @_; + my $self = shift; local %ENV = $self->_get_env(); my ($stdout, $stderr); my $result = - IPC::Run::run [ $self->installed_command('pg_config'), $option ], + IPC::Run::run [ $self->installed_command('pg_config'), @_ ], '>', \$stdout, '2>', \$stderr or die "could not execute pg_config"; chomp($stdout); -- 2.25.1
From 4d145a96483c9cdda07b2c60da76c03a0524bc09 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan <and...@dunslane.net> Date: Mon, 13 Jun 2022 18:19:39 -0400 Subject: [PATCH 2/2] Use installed postgresql.conf.sample for GUC sanity TAP test The current code looks for the sample file in the source directory, but it seems better to test against the installed sample file. --- src/test/modules/test_misc/t/003_check_guc.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl index 60459ef759..3ed905e7a0 100644 --- a/src/test/modules/test_misc/t/003_check_guc.pl +++ b/src/test/modules/test_misc/t/003_check_guc.pl @@ -33,10 +33,11 @@ my $not_in_sample = $node->safe_psql( ORDER BY 1"); my @not_in_sample_array = split("\n", lc($not_in_sample)); -# TAP tests are executed in the directory of the test, in the source tree, -# even for VPATH builds, so rely on that to find postgresql.conf.sample. -my $rootdir = "../../../.."; -my $sample_file = "$rootdir/src/backend/utils/misc/postgresql.conf.sample"; +# use the sample file from the temp install +my $share_dir = $node->config_data('--sharedir'); +chomp $share_dir; +$share_dir =~ s/^SHAREDIR = //; +my $sample_file = "$share_dir/postgresql.conf.sample"; # List of all the GUCs found in the sample file. my @gucs_in_file; -- 2.25.1