]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use command_ok for pg_regress calls in 002_pg_upgrade and 027_stream_regress
authorAndrew Dunstan <andrew@dunslane.net>
Wed, 1 Apr 2026 17:55:21 +0000 (13:55 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Thu, 2 Apr 2026 12:13:44 +0000 (08:13 -0400)
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
src/test/recovery/t/027_stream_regress.pl

index cd2d2f3007863a66ab6caf0d57d263f6f98bcc39..0a4121fdc4d9f4c43edbc0fc3c0f703689609596 100644 (file)
@@ -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.
index 259fd680ff3679a9c15bb51552d8352bfd164b31..ae9772978494330cd339022224e8a798dedbed65 100644 (file)
@@ -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');