From 11915e2b917ea643fc97cdc0044b3fc46d27698d Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <dgustafsson@postgresql.org>
Date: Sat, 26 Nov 2022 20:58:09 +0100
Subject: [PATCH v2] Consider a failed test process as a failed test

Commit 55de145d1cf added reporting of child process failures, but the
test suite is still allowed to pass even if the process failed. Since
regress tests are higher level tests, a false positive is more likely
in this case so report failed test processes as failed tests.

Reported-by: Andres Freund <andres@anarazel.de>
Discussion: tbd
Discussion: https://postgr.es/m/20221122235636.4frx7hjterq6bmls@awork3.anarazel.de
---
 src/test/regress/pg_regress.c | 74 +++++++++++++++++++++--------------
 1 file changed, 45 insertions(+), 29 deletions(-)

diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index dda076847a..ae324b2eba 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -1713,38 +1713,48 @@ run_schedule(const char *schedule, test_start_function startfunc,
 				differ |= newdiff;
 			}
 
-			if (differ)
+			/*
+			 * If the test process failed we explicitly treat the test as a
+			 * failed run regardless.
+			 */
+			if (statuses[i] != 0)
 			{
-				bool		ignore = false;
-				_stringlist *sl;
-
-				for (sl = ignorelist; sl != NULL; sl = sl->next)
+				status(_("FAILED"));
+				fail_count++;
+				log_child_failure(statuses[i]);
+			}
+			else
+			{
+				if (differ)
 				{
-					if (strcmp(tests[i], sl->str) == 0)
+					bool		ignore = false;
+					_stringlist *sl;
+
+					for (sl = ignorelist; sl != NULL; sl = sl->next)
 					{
-						ignore = true;
-						break;
+						if (strcmp(tests[i], sl->str) == 0)
+						{
+							ignore = true;
+							break;
+						}
+					}
+					if (ignore)
+					{
+						status(_("failed (ignored)"));
+						fail_ignore_count++;
+					}
+					else
+					{
+						status(_("FAILED"));
+						fail_count++;
 					}
-				}
-				if (ignore)
-				{
-					status(_("failed (ignored)"));
-					fail_ignore_count++;
 				}
 				else
 				{
-					status(_("FAILED"));
-					fail_count++;
+					status(_("ok    "));	/* align with FAILED */
+					success_count++;
 				}
 			}
-			else
-			{
-				status(_("ok    "));	/* align with FAILED */
-				success_count++;
-			}
-
-			if (statuses[i] != 0)
-				log_child_failure(statuses[i]);
 
 			INSTR_TIME_SUBTRACT(stoptimes[i], starttimes[i]);
 			status(_(" %8.0f ms"), INSTR_TIME_GET_MILLISEC(stoptimes[i]));
@@ -1815,20 +1825,26 @@ run_single_test(const char *test, test_start_function startfunc,
 		differ |= newdiff;
 	}
 
-	if (differ)
+	if (exit_status != 0)
 	{
 		status(_("FAILED"));
 		fail_count++;
+		log_child_failure(exit_status);
 	}
 	else
 	{
-		status(_("ok    "));	/* align with FAILED */
-		success_count++;
+		if (differ)
+		{
+			status(_("FAILED"));
+			fail_count++;
+		}
+		else
+		{
+			status(_("ok    "));	/* align with FAILED */
+			success_count++;
+		}
 	}
 
-	if (exit_status != 0)
-		log_child_failure(exit_status);
-
 	INSTR_TIME_SUBTRACT(stoptime, starttime);
 	status(_(" %8.0f ms"), INSTR_TIME_GET_MILLISEC(stoptime));
 
-- 
2.32.1 (Apple Git-133)

