Skip to content

Commit c8987ea

Browse files
committed
Make PG_TEST_NOCLEAN work for temporary directories in TAP tests
When set, this environment variable was only effective for data directories but not for all the other temporary files created by PostgreSQL::Test::Utils. Keeping the temporary files after a successful run can be useful for debugging purposes. The documentation is updated to reflect the new behavior, with contents available in doc/ since v16 and in src/test/perl/README since v15. Author: Jacob Champion Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAAWbhmgHtDH1SGZ+Fw05CsXtE0mzTmjbuUxLB9mY9iPKgM6cUw@mail.gmail.com Discussion: https://postgr.es/m/YyPd9unV14SX2bLF@paquier.xyz Backpatch-through: 11
1 parent 260dbf1 commit c8987ea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/test/perl/TestLib.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ sub all_tests_passing
268268
269269
Securely create a temporary directory inside C<$tmp_check>, like C<mkdtemp>,
270270
and return its name. The directory will be removed automatically at the
271-
end of the tests.
271+
end of the tests, unless the environment variable PG_TEST_NOCLEAN is provided.
272272
273273
If C<prefix> is given, the new directory is templated as C<${prefix}_XXXX>.
274274
Otherwise the template is C<tmp_test_XXXX>.
@@ -282,7 +282,7 @@ sub tempdir
282282
return File::Temp::tempdir(
283283
$prefix . '_XXXX',
284284
DIR => $tmp_check,
285-
CLEANUP => 1);
285+
CLEANUP => not defined $ENV{'PG_TEST_NOCLEAN'});
286286
}
287287

288288
=pod
@@ -297,7 +297,8 @@ name, to avoid path length issues.
297297
sub tempdir_short
298298
{
299299

300-
return File::Temp::tempdir(CLEANUP => 1);
300+
return File::Temp::tempdir(
301+
CLEANUP => not defined $ENV{'PG_TEST_NOCLEAN'});
301302
}
302303

303304
=pod

0 commit comments

Comments
 (0)