Don't clobber test exit code at cleanup in LDAP/Kerberors tests
authorHeikki Linnakangas <[email protected]>
Sun, 7 Apr 2024 17:21:27 +0000 (20:21 +0300)
committerHeikki Linnakangas <[email protected]>
Sun, 7 Apr 2024 17:22:06 +0000 (20:22 +0300)
If the test script die()d before running the first test, the whole test
was interpreted as SKIPped rather than failed. The PostgreSQL::Cluster
module got this right.

Backpatch to all supported versions.

Discussion: https://www.postgresql.org/message-id/fb898a70-3a88-4629-88e9-f2375020061d@iki.fi

src/test/kerberos/t/001_auth.pl
src/test/ldap/LdapServer.pm

index 0deb9bffc8de9e8cc435a8d577de7c6b43042b2b..d74e4af464e2a2ecc49fafcdacacae5b3c724dcc 100644 (file)
@@ -203,7 +203,12 @@ system_or_bail $krb5kdc, '-P', $kdc_pidfile;
 
 END
 {
-   kill 'INT', `cat $kdc_pidfile` if -f $kdc_pidfile;
+   # take care not to change the script's exit value
+   my $exit_code = $?;
+
+   kill 'INT', `cat $kdc_pidfile` if defined($kdc_pidfile) && -f $kdc_pidfile;
+
+   $? = $exit_code;
 }
 
 note "setting up PostgreSQL instance";
index 1d680d82900aaf444cf5579100440f84c22221ab..2ff580e5d468dcc3a38cc5cbeae78cc2938a227a 100644 (file)
@@ -145,6 +145,9 @@ INIT
 
 END
 {
+   # take care not to change the script's exit value
+   my $exit_code = $?;
+
    foreach my $server (@servers)
    {
        next unless -f $server->{pidfile};
@@ -152,6 +155,8 @@ END
        chomp $pid;
        kill 'INT', $pid;
    }
+
+   $? = $exit_code;
 }
 
 =pod