Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Add PostgreSQL::Test::Cluster::config_data()
authorMichael Paquier <michael@paquier.xyz>
Tue, 8 Feb 2022 01:35:27 +0000 (10:35 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 8 Feb 2022 01:35:27 +0000 (10:35 +0900)
This is useful to grab some configuration information from a node
already set up, and I personally found two cases for it: pg_upgrade and
a test to emulate check_guc.

Author: Michael Paquier
Discussion: https://postgr.es/m/20211129030833.GJ17618@telsasoft.com
Discussion: https://postgr.es/m/YJ8xTmLQkotVLpN5@paquier.xyz

src/test/perl/PostgreSQL/Test/Cluster.pm

index 265f3ae657419fddd80531bcf76ce877b147948b..41beadff9dd7fafc470e2ab3b5462dae907cb919 100644 (file)
@@ -327,6 +327,31 @@ sub install_path
 
 =pod
 
+=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.
+
+=cut
+
+sub config_data
+{
+   my ($self, $option) = @_;
+   local %ENV = $self->_get_env();
+
+   my ($stdout, $stderr);
+   my $result =
+     IPC::Run::run [ $self->installed_command('pg_config'), $option ],
+     '>', \$stdout, '2>', \$stderr
+     or die "could not execute pg_config";
+   chomp($stdout);
+   $stdout =~ s/\r$//;
+
+   return $stdout;
+}
+
+=pod
+
 =item $node->info()
 
 Return a string containing human-readable diagnostic information (paths, etc)