On 02.10.23 09:12, Peter Eisentraut wrote:
1) Remove useless entries from "unlike" lists.  Runs that are not
    listed in "like" don't need to be excluded in "unlike".

2) Ensure there is always a "like" list, even if it is empty.  This
    makes the test more self-documenting.

I also added code that checks 1 and 2 automatically and issues a message
for violations.

I have recently discovered that the same code also exists separately in the test_pg_dump module test. This should probably be kept consistent. So here is a patch that adds the same checks there. In this case, we didn't need to fix any of the existing subtests.

I plan to commit this soon if there are no concerns.
From 0d564bc2ff626b28ef450605d789a0ea42b25992 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Mon, 5 Feb 2024 11:22:01 +0100
Subject: [PATCH] Apply pg_dump test cleanups to test_pg_dump as well

Apply the changes from 41a284411e0 to the test_pg_dump module as well.
Here, we just apply the new test consistency checks, but we don't need
to fix any existing tests.
---
 src/test/modules/test_pg_dump/t/001_base.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/test/modules/test_pg_dump/t/001_base.pl 
b/src/test/modules/test_pg_dump/t/001_base.pl
index 339e7459ca7..b8c30c23872 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -857,6 +857,22 @@
 
        foreach my $test (sort keys %tests)
        {
+               # Check for proper test definitions
+               #
+               # There should be a "like" list, even if it is empty.  (This
+               # makes the test more self-documenting.)
+               if (!defined($tests{$test}->{like}))
+               {
+                       die "missing \"like\" in test \"$test\"";
+               }
+               # Check for useless entries in "unlike" list.  Runs that are
+               # not listed in "like" don't need to be excluded in "unlike".
+               if ($tests{$test}->{unlike}->{$test_key}
+                       && !defined($tests{$test}->{like}->{$test_key}))
+               {
+                       die "useless \"unlike\" entry \"$test_key\" in test 
\"$test\"";
+               }
+
                # Run the test listed as a like, unless it is specifically noted
                # as an unlike (generally due to an explicit exclusion or 
similar).
                if ($tests{$test}->{like}->{$test_key}
-- 
2.43.0

Reply via email to