line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Test::DataDirs::Exporter - manage t/data and t/temp directories for your tests |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 VERSION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
version 0.1.2 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Like the base class L, this is a convenience which |
12
|
|
|
|
|
|
|
provides data directories from which to source information for your |
13
|
|
|
|
|
|
|
tests, and temp directories you can write data. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Declare some temp and data directories you need in your test script as |
16
|
|
|
|
|
|
|
below. These are implicitly relative to C<< t/temp/ >> |
17
|
|
|
|
|
|
|
and C<< t/data/ >>. Then you may refer to them |
18
|
|
|
|
|
|
|
using the imported variables, and assume the dirs |
19
|
|
|
|
|
|
|
exist and that the temp dirs have been (re-)created. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# File: t/test-01.t |
22
|
|
|
|
|
|
|
use Test::DataDirs::Exporter ( |
23
|
|
|
|
|
|
|
temp => [temp_stuff => 'actual-dir', |
24
|
|
|
|
|
|
|
more_temp => 'another-dir'], |
25
|
|
|
|
|
|
|
data => [data_stuff => 'actual-dir'], |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
print "My test data is checked into $data_stuff\n" |
29
|
|
|
|
|
|
|
print "below $data_dir\n" |
30
|
|
|
|
|
|
|
# Prints (except with absolute paths): |
31
|
|
|
|
|
|
|
# My test data is checked into t/data/test-01/actual-dir |
32
|
|
|
|
|
|
|
# below t/data/test-01 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
print "I can write temp data into $temp_stuff\n" |
35
|
|
|
|
|
|
|
print "and $more_temp, "below $temp_dir\n" |
36
|
|
|
|
|
|
|
# Prints (except with absolute paths): |
37
|
|
|
|
|
|
|
# I can write temp data into t/temp/test-01/actual-dir |
38
|
|
|
|
|
|
|
# and t/temp/test-01/another-dir below t/data/test-01 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
package Test::DataDirs::Exporter; |
46
|
3
|
|
|
3
|
|
18608
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
91
|
|
47
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
72
|
|
48
|
3
|
|
|
3
|
|
950
|
use Test::DataDirs; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
63
|
|
49
|
3
|
|
|
3
|
|
11
|
use Carp; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
286
|
|
50
|
|
|
|
|
|
|
our @CARP_NOT = 'Test::DataDirs'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
our $VERSION = '0.1.2'; # VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub import { |
55
|
8
|
|
|
8
|
|
3791
|
my $package = shift; |
56
|
8
|
|
|
|
|
19
|
my $target = caller; |
57
|
|
|
|
|
|
|
|
58
|
8
|
|
|
|
|
162
|
my $dirs = Test::DataDirs->new(@_)->dirs; |
59
|
3
|
|
|
3
|
|
12
|
no strict 'refs'; ## no critic |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
194
|
|
60
|
3
|
|
|
|
|
20
|
for my $name (keys %$dirs) { |
61
|
14
|
|
|
|
|
16
|
*{"${target}::$name"} = \$dirs->{$name}; |
|
14
|
|
|
|
|
2172
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |