postgres.git / summary / log / commit / refs
commit bb6ae9707c1789c9d2036c9bbd35965a01e1b214
Author: Andrew Dunstan <andrew@dunslane.net>
Date: Wed Apr 01 17:55:21 2026 +0000
Use command_ok for pg_regress calls in 002_pg_upgrade and 027_stream_regress
Now that command_ok() captures and displays failure output, use it
instead of system() plus manual diff-dumping in these two tests. This
simplifies both scripts and produces consistent, truncated output on
failure.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 40 ++++++++--------------
src/test/recovery/t/027_stream_regress.pl | 55 +++++++++----------------------
2 files changed, 29 insertions(+), 66 deletions(-)
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index cd2d2f30078..0a4121fdc4d 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -280,32 +280,20 @@ else
# --inputdir points to the path of the input files.
my $inputdir = "$srcdir/src/test/regress";
- note 'running regression tests in old instance';
- my $rc =
- system($ENV{PG_REGRESS}
- . " $extra_opts "
- . "--dlpath=\"$dlpath\" "
- . "--bindir= "
- . "--host="
- . $oldnode->host . " "
- . "--port="
- . $oldnode->port . " "
- . "--schedule=$srcdir/src/test/regress/parallel_schedule "
- . "--max-concurrent-tests=20 "
- . "--inputdir=\"$inputdir\" "
- . "--outputdir=\"$outputdir\"");
- if ($rc != 0)
- {
- # Dump out the regression diffs file, if there is one
- my $diffs = "$outputdir/regression.diffs";
- if (-e $diffs)
- {
- print "=== dumping $diffs ===\n";
- print slurp_file($diffs);
- print "=== EOF ===\n";
- }
- }
- is($rc, 0, 'regression tests pass');
+ command_ok(
+ [
+ $ENV{PG_REGRESS},
+ split(' ', $extra_opts),
+ "--dlpath=$dlpath",
+ '--bindir=',
+ '--host=' . $oldnode->host,
+ '--port=' . $oldnode->port,
+ "--schedule=$srcdir/src/test/regress/parallel_schedule",
+ '--max-concurrent-tests=20',
+ "--inputdir=$inputdir",
+ "--outputdir=$outputdir"
+ ],
+ 'regression tests in old instance');
}
# Initialize a new node for the upgrade.
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index 259fd680ff3..ae977297849 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -68,48 +68,23 @@ my $outputdir = $PostgreSQL::Test::Utils::tmp_check;
# Run the regression tests against the primary.
my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || "";
-my $rc =
- system($ENV{PG_REGRESS}
- . " $extra_opts "
- . "--dlpath=\"$dlpath\" "
- . "--bindir= "
- . "--host="
- . $node_primary->host . " "
- . "--port="
- . $node_primary->port . " "
- . "--schedule=../regress/parallel_schedule "
- . "--max-concurrent-tests=20 "
- . "--inputdir=../regress "
- . "--outputdir=\"$outputdir\"");
-
-# Regression diffs are only meaningful if both the primary and the standby
-# are still alive after a regression test failure.
+command_ok(
+ [
+ $ENV{PG_REGRESS},
+ split(' ', $extra_opts),
+ "--dlpath=$dlpath",
+ '--bindir=',
+ '--host=' . $node_primary->host,
+ '--port=' . $node_primary->port,
+ '--schedule=../regress/parallel_schedule',
+ '--max-concurrent-tests=20',
+ '--inputdir=../regress',
+ "--outputdir=$outputdir"
+ ],
+ 'regression tests pass');
+
my $primary_alive = $node_primary->is_alive;
my $standby_alive = $node_standby_1->is_alive;
-if ($rc != 0 && $primary_alive && $standby_alive)
-{
- # Dump out the regression diffs file, if there is one
- my $diffs = "$outputdir/regression.diffs";
- if (-e $diffs)
- {
- # Dump portions of the diff file.
- my ($head, $tail) = read_head_tail($diffs);
-
- diag("=== dumping $diffs (head) ===");
- foreach my $line (@$head)
- {
- diag($line);
- }
-
- diag("=== dumping $diffs (tail) ===");
- foreach my $line (@$tail)
- {
- diag($line);
- }
- diag("=== EOF ===");
- }
-}
-is($rc, 0, 'regression tests pass');
is($primary_alive, 1, 'primary alive after regression test run');
is($standby_alive, 1, 'standby alive after regression test run');
[parent: b8da9869b850]