summaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/perl/PostgreSQL/Test')
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm19
-rw-r--r--src/test/perl/PostgreSQL/Test/Utils.pm25
2 files changed, 44 insertions, 0 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 05bd94609d4..8759ed2cbba 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -2801,6 +2801,25 @@ sub command_fails_like
=pod
+=item $node->command_ok_or_fails_like(...)
+
+PostgreSQL::Test::Utils::command_ok_or_fails_like with our connection parameters. See command_ok(...)
+
+=cut
+
+sub command_ok_or_fails_like
+{
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my $self = shift;
+
+ local %ENV = $self->_get_env();
+
+ return PostgreSQL::Test::Utils::command_ok_or_fails_like(@_);
+}
+
+=pod
+
=item $node->command_checks_all(...)
PostgreSQL::Test::Utils::command_checks_all with our connection parameters. See
diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
index d1ad131eadf..7d7ca83495f 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -89,6 +89,7 @@ our @EXPORT = qw(
command_like
command_like_safe
command_fails_like
+ command_ok_or_fails_like
command_checks_all
$windows_os
@@ -1067,6 +1068,30 @@ sub command_fails_like
=pod
+=item command_ok_or_fails_like(cmd, expected_stdout, expected_stderr, test_name)
+
+Check that the command either succeeds or fails with an error that matches the
+given regular expressions.
+
+=cut
+
+sub command_ok_or_fails_like
+{
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ my ($cmd, $expected_stdout, $expected_stderr, $test_name) = @_;
+ my ($stdout, $stderr);
+ print("# Running: " . join(" ", @{$cmd}) . "\n");
+ my $result = IPC::Run::run $cmd, '>' => \$stdout, '2>' => \$stderr;
+ if (!$result)
+ {
+ like($stdout, $expected_stdout, "$test_name: stdout matches");
+ like($stderr, $expected_stderr, "$test_name: stderr matches");
+ }
+ return $result;
+}
+
+=pod
+
=item command_checks_all(cmd, ret, out, err, test_name)
Run a command and check its status and outputs.