Skip to content

Commit 78a26c3

Browse files
committed
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 88802e0 introduced retention on failure. Reviewed by Daniel Gustafsson. Discussion: https://postgr.es/m/20200202170155.GA3264196@rfd.leadboat.com
1 parent 1fb8976 commit 78a26c3

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

src/test/perl/PostgresNode.pm

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,20 +1206,6 @@ sub can_bind
12061206
return $ret;
12071207
}
12081208

1209-
# Retain the errno on die() if set, else assume a generic errno of 1.
1210-
# This will instruct the END handler on how to handle artifacts left
1211-
# behind from tests.
1212-
$SIG{__DIE__} = sub {
1213-
if ($!)
1214-
{
1215-
$died = $!;
1216-
}
1217-
else
1218-
{
1219-
$died = 1;
1220-
}
1221-
};
1222-
12231209
# Automatically shut down any still-running nodes when the test script exits.
12241210
# Note that this just stops the postmasters (in the same order the nodes were
12251211
# created in). Any temporary directories are deleted, in an unspecified
@@ -1238,8 +1224,7 @@ END
12381224
next if defined $ENV{'PG_TEST_NOCLEAN'};
12391225

12401226
# clean basedir on clean test invocation
1241-
$node->clean_node
1242-
if TestLib::all_tests_passing() && !defined $died && !$exit_code;
1227+
$node->clean_node if $exit_code == 0 && TestLib::all_tests_passing();
12431228
}
12441229

12451230
$? = $exit_code;

src/test/perl/TestLib.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ INIT
131131
END
132132
{
133133

134-
# Preserve temporary directory for this test on failure
135-
$File::Temp::KEEP_ALL = 1 unless all_tests_passing();
134+
# Test files have several ways of causing prove_check to fail:
135+
# 1. Exit with a non-zero status.
136+
# 2. Call ok(0) or similar, indicating that a constituent test failed.
137+
# 3. Deviate from the planned number of tests.
138+
#
139+
# Preserve temporary directories after (1) and after (2).
140+
$File::Temp::KEEP_ALL = 1 unless $? == 0 && all_tests_passing();
136141
}
137142

138143
sub all_tests_passing

0 commit comments

Comments
 (0)