Add test for postgresql.conf.sample line syntax
authorDaniel Gustafsson <[email protected]>
Fri, 14 Nov 2025 22:44:56 +0000 (23:44 +0100)
committerDaniel Gustafsson <[email protected]>
Fri, 14 Nov 2025 22:44:56 +0000 (23:44 +0100)
All GUCs in postgresql.conf.sample should be set to the default
value and be commented out.  This syntax was however not tested
for, making omissions easy to miss.  Add a test which check all
lines for syntax.

Author: Daniel Gustafsson <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Discussion: https://postgr.es/m/19727040-3EE4-4719-AF4F-2548544113D7@yesql.se

src/test/modules/test_misc/t/003_check_guc.pl

index 5ae23192a47c9e3df3ffd001229f448b6a3f985f..51349e98e931380976578951d4986f9084e535d1 100644 (file)
@@ -56,7 +56,7 @@ while (my $line = <$contents>)
        # file.
        # - Valid configuration options are followed immediately by " = ",
        # with one space before and after the equal sign.
-       if ($line =~ m/^#?([_[:alnum:]]+) = .*/)
+       if ($line =~ m/^#([_[:alnum:]]+) = .*/)
        {
                # Lower-case conversion matters for some of the GUCs.
                my $param_name = lc($1);
@@ -69,7 +69,12 @@ while (my $line = <$contents>)
                # Update the list of GUCs found in the sample file, for the
                # follow-up tests.
                push @gucs_in_file, $param_name;
+
+               next;
        }
+       # Make sure each line starts with either a # or whitespace
+       fail("$line missing initial # in postgresql.conf.sample")
+         if $line =~ /^\s*[^#\s]/;
 }
 
 close $contents;