diff options
author | Noah Misch | 2020-02-05 16:26:41 +0000 |
---|---|---|
committer | Noah Misch | 2020-02-05 16:26:41 +0000 |
commit | bf989aaf35613ed2c2a66e120ca600e7b9da4f82 (patch) | |
tree | a54d9fe5e36beb5de6b2c7cb2936c54e9c4c31b9 | |
parent | 815c2f0972c8386aba7c606f1ee6690d13b04db2 (diff) |
When a TAP file has non-zero exit status, retain temporary directories.
PostgresNode already retained base directories in such cases. Stop
using $SIG{__DIE__}, which is redundant with the exit status check, in
lieu of proliferating it to TestLib. Back-patch to 9.6, where commit
88802e068017bee8cea7a5502a712794e761c7b5 introduced retention on
failure.
Reviewed by Daniel Gustafsson.
Discussion: https://postgr.es/m/20200202170155.GA3264196@rfd.leadboat.com
-rw-r--r-- | src/test/perl/PostgresNode.pm | 17 | ||||
-rw-r--r-- | src/test/perl/TestLib.pm | 9 |
2 files changed, 8 insertions, 18 deletions
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index bf095a7adb7..9575268bd77 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -1233,20 +1233,6 @@ sub can_bind return $ret; } -# Retain the errno on die() if set, else assume a generic errno of 1. -# This will instruct the END handler on how to handle artifacts left -# behind from tests. -$SIG{__DIE__} = sub { - if ($!) - { - $died = $!; - } - else - { - $died = 1; - } -}; - # Automatically shut down any still-running nodes when the test script exits. # Note that this just stops the postmasters (in the same order the nodes were # created in). Any temporary directories are deleted, in an unspecified @@ -1265,8 +1251,7 @@ END next if defined $ENV{'PG_TEST_NOCLEAN'}; # clean basedir on clean test invocation - $node->clean_node - if TestLib::all_tests_passing() && !defined $died && !$exit_code; + $node->clean_node if $exit_code == 0 && TestLib::all_tests_passing(); } $? = $exit_code; diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 458b8013796..65ee0425b06 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -183,8 +183,13 @@ INIT END { - # Preserve temporary directory for this test on failure - $File::Temp::KEEP_ALL = 1 unless all_tests_passing(); + # Test files have several ways of causing prove_check to fail: + # 1. Exit with a non-zero status. + # 2. Call ok(0) or similar, indicating that a constituent test failed. + # 3. Deviate from the planned number of tests. + # + # Preserve temporary directories after (1) and after (2). + $File::Temp::KEEP_ALL = 1 unless $? == 0 && all_tests_passing(); } =pod |