Test::TempDir(3pm)
π Test::TempDir β bestie edition π
okay so you're looking at the Test::TempDir(3pm) manual page, and I need you to sit down for this one because there's some lore here. This is a Perl module for making temporary files while you're testing. Very demure. Very mindful. Except for the part where it's deprecated and might delete your whole $TMPDIR. More on that in a sec, bestie. π«Ά
β¨ NAME β¨
Test::TempDir β (DEPRECATED) temporary files support for testing. Yes the deprecated part is literally in the name section. The module is telling on itself. Iconic honestly.
πΈ VERSION πΈ
version 0.11
π DEPRECATION NOTICE π
okay so this is the part where I have to be real with you. There have been numerous issues found with this module, particularly with its use of locks β which are unreliable and may result in your entire $TMPDIR being deleted π β and with MSWin32 compatibility. As well, it uses Moose, which is nowadays considered to be heavier than necessary.
bestie. it could delete your whole $TMPDIR. that's not a vibe check that's a vibe threat. π
Test::TempDir::Tiny was written as a replacement. Please use it instead! fr fr. this is not a drill. π
π SYNOPSIS π
use Test::TempDir;
my $test_tempdir = temp_root();
my ( $fh, $file ) = tempfile();
my $directory_scratch_obj = scratch();
look at that. three lines. chef's kiss. the way that temp_root just exists for you. β¨
π¦ DESCRIPTION π¦
Test::TempDir provides temporary directory creation with testing in mind. It's giving "I got you, bestie, here's a lil sandbox."
The differences between using this and using File::Temp are:
- If
t/tmpis available (writable, creatable, etc) it's preferred over$ENV{TMPDIR}etc. Otherwise a temporary directory will be used.
This is temp_root π
- Lock files are used on
t/tmp, to prevent race conditions when running under a parallel test harness. teamwork makes the dream work, but like, with locks. - The
temp_rootis cleaned at the end of a test run, but not if tests failed. temp_rootis emptied at the beginning of a test run unconditionally. no questions asked. it does not care about your feelings or your leftover files. π§Ή- The default policy is not to clean the individual
tempfilesandtempdirswithintemp_root, in order to aid in debugging of failed tests. so when something breaks you can go look at the crime scene. very thoughtful actually. π
π EXPORTS π
π temp_root
The root of the temporary stuff. that's it. that's the whole description. she's concise. she ate. β
π tempfile, tempdir
Wrappers for the File::Temp functions of the same name.
The default options are changed to use temp_root for DIR and disable CLEANUP, but these are overridable. so you can absolutely do your own thing, no one's stopping you. π«Ά
π scratch
Loads Directory::Scratch and instantiates a new one, with the same default options as tempfile and tempdir. consistent queen behavior. β¨
π₯ SEE ALSO π₯
File::Temp,Directory::ScratchPath::Class
π¬ SUPPORT π¬
Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Test-TempDir> (or bug-Test-TempDir@rt.cpan.org <mailto:bug-Test-TempDir@rt.cpan.org>).
There is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/perl-qa.html>.
There is also an irc channel available for users of this distribution, at #perl on irc.perl.org <irc://irc.perl.org/#perl-qa>.
so like. if you find a bug, you have options. RT, email, mailing list, irc. pick your fighter. π
π AUTHOR π
XXXX XXX'XX (Yuval Kogman) <nothingmuch@woobling.org>
(yes the name is literally XXXX XXX'XX, we don't ask questions, we respect the mystery. π)
πΈ CONTRIBUTORS πΈ
- Karen Etheridge <ether@cpan.org>
- Florian Ragwitz <rafl@debian.org>
the girlies who showed up. we love them. π
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2006 by XXXX XXX'XX (Yuval Kogman).
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay bestie that's the whole page!! π
cute lil sign-off for you: this was perl v5.34.0, dated 2022-07-11, and it lives on your system as Test::TempDir(3pm). now go use Test::TempDir::Tiny instead, I'm begging you, the locks are not okay ππβ¨
π¦ where this page comes from
- debian bookworm: libtest-tempdir-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-tempdir-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-tempdir-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-tempdir-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-tempdir-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms