line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Test::Case; |
2
|
9
|
|
|
9
|
|
110747
|
use Path::Class (); |
|
9
|
|
|
|
|
468788
|
|
|
9
|
|
|
|
|
8791
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Moose boilerplate {{{ |
8
|
|
|
|
|
|
|
sub new { |
9
|
9
|
|
|
9
|
0
|
640
|
my $class = shift; |
10
|
9
|
|
|
|
|
33
|
my %args = @_; |
11
|
|
|
|
|
|
|
|
12
|
9
|
|
66
|
|
|
63
|
$args{test_dir} ||= do { # default |
13
|
7
|
|
|
|
|
7294
|
require FindBin; |
14
|
7
|
|
|
|
|
20230
|
Path::Class::Dir->new( |
15
|
|
|
|
|
|
|
$FindBin::Bin, ($0 =~ /^.*\/(.*?)(?:--.*?)?\.t$/) |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
9
|
|
|
|
|
1286
|
bless \%args, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
49
|
|
|
49
|
0
|
3474
|
sub test_dir { shift->{test_dir} } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub pm_files { |
25
|
14
|
|
|
14
|
0
|
1420
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
14
|
100
|
|
|
|
63
|
if (!exists($self->{pm_files})) { # lazy |
28
|
12
|
|
|
|
|
717
|
$self->{pm_files} = [ |
29
|
|
|
|
|
|
|
sort |
30
|
24
|
50
|
|
|
|
7951
|
map { $_->basename } |
31
|
8
|
|
|
|
|
36
|
grep { -f $_ && /\.pm$/ } |
32
|
|
|
|
|
|
|
$self->test_dir->children |
33
|
|
|
|
|
|
|
]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
14
|
|
|
|
|
384
|
return $self->{pm_files}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub test_files { |
40
|
14
|
|
|
14
|
0
|
34
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
14
|
100
|
|
|
|
80
|
if (!exists($self->{test_files})) { # lazy |
43
|
12
|
|
|
|
|
741
|
$self->{test_files} = [ |
44
|
|
|
|
|
|
|
sort |
45
|
24
|
50
|
|
|
|
6761
|
map { $_->basename } |
46
|
8
|
|
|
|
|
37
|
grep { -f $_ && /\.(pl|t)$/ } |
47
|
|
|
|
|
|
|
$self->test_dir->children |
48
|
|
|
|
|
|
|
]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
14
|
|
|
|
|
151
|
return $self->{test_files}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
# }}} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub load_pm_file { |
56
|
12
|
|
|
12
|
0
|
27
|
my $self = shift; |
57
|
12
|
|
|
|
|
32
|
my $pm_file = shift; |
58
|
|
|
|
|
|
|
|
59
|
12
|
|
|
|
|
313
|
require $pm_file; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub prepare_pm_files { |
63
|
8
|
|
|
8
|
0
|
16
|
my $self = shift; |
64
|
8
|
|
|
|
|
30
|
my $dir = $self->test_dir; |
65
|
8
|
|
|
|
|
15
|
map { $dir->file($_) } @{ $self->pm_files } |
|
12
|
|
|
|
|
696
|
|
|
8
|
|
|
|
|
29
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub load_pm_files { |
69
|
5
|
|
|
5
|
0
|
178
|
my $self = shift; |
70
|
5
|
|
|
|
|
20
|
foreach my $pm_file ($self->prepare_pm_files) { |
71
|
8
|
|
|
|
|
169264
|
$self->load_pm_file($pm_file); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub prepare_test_files { |
76
|
8
|
|
|
8
|
0
|
26
|
my $self = shift; |
77
|
8
|
|
|
|
|
51
|
my $dir = $self->test_dir; |
78
|
8
|
|
|
|
|
27
|
map { $dir->file($_) } @{ $self->test_files } |
|
12
|
|
|
|
|
838
|
|
|
8
|
|
|
|
|
33
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub run_test_file { |
82
|
4
|
|
|
4
|
0
|
9
|
my $self = shift; |
83
|
4
|
|
|
|
|
8
|
my $file = shift; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
package main; |
86
|
4
|
|
|
|
|
39
|
eval Path::Class::file($file)->slurp; |
87
|
4
|
50
|
|
|
|
1564
|
die $@ if $@; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub create_test_body { |
91
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
92
|
1
|
|
|
|
|
8
|
my $dir = $self->test_dir; |
93
|
1
|
|
|
|
|
3
|
my $body = ''; |
94
|
1
|
|
|
|
|
2
|
foreach my $file (@{ $self->pm_files }, @{ $self->test_files }) { |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
95
|
4
|
|
|
|
|
1061
|
$body .= "\n{\n" . $dir->file($file)->slurp . "\n}\n"; |
96
|
|
|
|
|
|
|
} |
97
|
1
|
|
|
|
|
285
|
return $body; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub run_tests { |
101
|
3
|
|
|
3
|
0
|
32
|
my $self = shift; |
102
|
|
|
|
|
|
|
my %args = ( |
103
|
2
|
|
|
2
|
|
4
|
before_first_pm => sub { }, |
104
|
1
|
|
|
1
|
|
2
|
after_last_pm => sub { }, |
105
|
2
|
|
|
2
|
|
3
|
before_pm => sub { }, |
106
|
2
|
|
|
2
|
|
9
|
after_pm => sub { }, |
107
|
2
|
|
|
2
|
|
6
|
before_first_t => sub { }, |
108
|
2
|
|
|
2
|
|
301
|
after_last_t => sub { }, |
109
|
2
|
|
|
2
|
|
5
|
before_t => sub { }, |
110
|
2
|
|
|
2
|
|
7
|
after_t => sub { }, |
111
|
3
|
|
|
|
|
75
|
@_, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
3
|
|
|
|
|
23
|
$args{before_first_pm}->(); |
115
|
3
|
|
|
|
|
15
|
foreach my $pm_file ($self->prepare_pm_files) { |
116
|
4
|
|
|
|
|
246
|
$args{before_pm}->($pm_file); |
117
|
4
|
|
|
|
|
22
|
$self->load_pm_file($pm_file); |
118
|
4
|
|
|
|
|
120308
|
$args{after_pm}->($pm_file); |
119
|
|
|
|
|
|
|
} |
120
|
3
|
|
|
|
|
33
|
$args{after_last_pm}->(); |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
27
|
$args{before_first_t}->(); |
123
|
3
|
|
|
|
|
18
|
for my $file ($self->prepare_test_files) { |
124
|
4
|
|
|
|
|
270
|
$args{before_t}->($file); |
125
|
4
|
|
|
|
|
23
|
$self->run_test_file($file); |
126
|
4
|
|
|
|
|
45
|
$args{after_t}->($file); |
127
|
|
|
|
|
|
|
} |
128
|
3
|
|
|
|
|
28
|
$args{after_last_t}->(); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |