1Test::TempDir(3) User Contributed Perl Documentation Test::TempDir(3)
2
3
4
6 Test::TempDir - Temporary files support for testing.
7
9 use Test::TempDir;
10
11 my $test_tempdir = temp_root();
12
13 my ( $fh, $file ) = tempfile();
14
15 my $directory_scratch_obj = scratch();
16
18 Test::TempDir provides temporary directory creation with testing in
19 mind.
20
21 The differences between using this and using File::Temp are:
22
23 · If "t/tmp" is available (writable, creatable, etc) it's preferred
24 over $ENV{TMPDIR} etc. Otherwise a temporary directory will be
25 used.
26
27 This is "temp_root"
28
29 · Lockfiles are used on "t/tmp", to prevent race conditions when
30 running under a parallel test harness.
31
32 · The "temp_root" is cleaned at the end of a test run, but not if
33 tests failed.
34
35 · "temp_root" is emptied at the begining of a test run
36 unconditionally.
37
38 · The default policy is not to clean the individual "tempfiles" and
39 "tempdirs" within "temp_root", in order to aid in debugging of
40 failed tests.
41
43 temp_root
44 The root of the temporary stuff.
45
46 tempfile
47 tempdir
48 Wrappers for the File::Temp functions of the same name.
49
50 The default options are changed to use "temp_root" for "DIR" and
51 disable "CLEANUP", but these are overridable.
52
53 scrach
54 Loads Directory::Scratch and instantiates a new one, with the same
55 default options as "tempfile" and "tempdir".
56
58 File::Temp, Directory::Scratch, Path::Class
59
61 This module is maintained using Git. You can get the latest version
62 from git://github.com/nothingmuch/test-tempdir.git
63 <git://github.com/nothingmuch/test-tempdir.git>.
64
66 Yuval Kogman <nothingmuch@woobling.org>
67
69 Copyright (c) 2008 Yuval Kogman. All rights reserved
70 This program is free software; you can redistribute
71 it and/or modify it under the same terms as Perl itself.
72
73
74
75perl v5.12.1 2009-08-11 Test::TempDir(3)