From 8245606fce82aadb5fd07fcd8d22770fc73906f9 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Thu, 4 Dec 2025 14:47:25 +0300
Subject: [PATCH v6 2/2] Improve error reporting in 027_stream_regress test

Previously, the 027_stream_regress test only reported that the regression
test had failed, without showing the actual error. The detailed failure
information was hidden in the regression.diffs file.

This commit improves the situation by including the head and tail of
regression.diffs directly in the failure message. This helps quickly
identify the root cause without needing to open extra files.

Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAN55FZ1D6KXvjSs7YGsDeadqCxNF3UUhjRAfforzzP0k-cE%3DbA%40mail.gmail.com
---
 src/test/recovery/t/027_stream_regress.pl | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index 589c79d97d3a..195e1eb83473 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -83,9 +83,7 @@ my $rc =
 	  . "--outputdir=\"$outputdir\"");
 
 # Regression diffs are only meaningful if both the primary and the standby
-# are still alive after a regression test failure.  A crash would cause a
-# useless increase in the log quantity, mostly filled with information
-# related to queries that could not run.
+# are still alive after a regression test failure.
 my $primary_alive = $node_primary->is_alive;
 my $standby_alive = $node_standby_1->is_alive;
 if ($rc != 0 && $primary_alive && $standby_alive)
@@ -94,9 +92,21 @@ if ($rc != 0 && $primary_alive && $standby_alive)
 	my $diffs = "$outputdir/regression.diffs";
 	if (-e $diffs)
 	{
-		print "=== dumping $diffs ===\n";
-		print slurp_file($diffs);
-		print "=== EOF ===\n";
+		# 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');
-- 
2.51.0

