line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Setup::Test::Flavor; |
2
|
4
|
|
|
4
|
|
6498
|
use Module::Setup::Test::Utils; |
|
4
|
|
|
|
|
32
|
|
|
4
|
|
|
|
|
33
|
|
3
|
4
|
|
|
4
|
|
28
|
use Carp (); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
65
|
|
4
|
4
|
|
|
4
|
|
24
|
use File::Find::Rule; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
49
|
|
5
|
4
|
|
|
4
|
|
2945
|
use Test::More; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
50
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
4
|
|
|
4
|
|
44
|
my $class = shift; |
9
|
4
|
|
|
|
|
13
|
my $caller = caller; |
10
|
4
|
|
|
|
|
13
|
my %args = @_; |
11
|
|
|
|
|
|
|
|
12
|
4
|
100
|
|
|
|
21
|
if ($args{for_test}) { |
13
|
4
|
|
|
4
|
|
28
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
152
|
|
14
|
4
|
|
|
4
|
|
20
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
477
|
|
15
|
1
|
|
|
48
|
|
6
|
*ok = sub ($;$) { 1 }; |
|
48
|
|
|
|
|
2462
|
|
16
|
1
|
|
|
9
|
|
5
|
*like = sub ($$;$) { 1 }; |
|
9
|
|
|
|
|
29
|
|
17
|
1
|
|
|
5
|
|
3
|
*plan = sub {}; |
|
5
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
12
|
for my $func (qw/ run_flavor_test name flavor files file dirs options default_dialog dialog /) { |
21
|
4
|
|
|
4
|
|
23
|
no strict 'refs'; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
4146
|
|
22
|
36
|
|
|
|
|
37
|
*{"$caller\::$func"} = \&{ $func }; |
|
36
|
|
|
|
|
143
|
|
|
36
|
|
|
|
|
64
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
65
|
strict->import; |
26
|
4
|
|
|
|
|
7619
|
warnings->import; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $tests = {}; |
30
|
|
|
|
|
|
|
sub name ($) { |
31
|
6
|
|
|
6
|
0
|
43
|
$tests->{module} = shift; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
sub flavor ($) { |
34
|
3
|
|
|
3
|
0
|
20
|
$tests->{flavor_class} = shift; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub files (@) { |
38
|
7
|
|
|
7
|
0
|
39
|
push @{ $tests->{files} }, @_; |
|
7
|
|
|
|
|
44
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub file (@) { |
42
|
19
|
|
|
19
|
0
|
121
|
my $file = shift; |
43
|
19
|
|
|
|
|
31
|
push @{ $tests->{files} }, { |
|
19
|
|
|
|
|
105
|
|
44
|
|
|
|
|
|
|
file => $file, |
45
|
|
|
|
|
|
|
likes => [ @_ ], |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub dirs (@) { |
50
|
7
|
|
|
7
|
0
|
41
|
push @{ $tests->{dirs} }, @_; |
|
7
|
|
|
|
|
32
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub options ($) { |
54
|
1
|
|
|
1
|
0
|
5
|
$tests->{options} = shift; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub run_flavor_test (&) { |
59
|
8
|
|
|
8
|
0
|
114
|
my $code = shift; |
60
|
8
|
|
|
|
|
65
|
$tests = { |
61
|
|
|
|
|
|
|
module => 'Default', |
62
|
|
|
|
|
|
|
files => [], |
63
|
|
|
|
|
|
|
dirs => [], |
64
|
|
|
|
|
|
|
options => {}, |
65
|
|
|
|
|
|
|
flavor_class => 'Default', |
66
|
|
|
|
|
|
|
}; |
67
|
8
|
|
|
|
|
53
|
$code->(); |
68
|
8
|
|
|
|
|
26
|
my $module = delete $tests->{module}; |
69
|
8
|
|
|
|
|
24
|
my $options = delete $tests->{options}; |
70
|
8
|
|
|
|
|
25
|
$options->{target} = 1; |
71
|
8
|
|
|
|
|
27
|
$options->{flavor_class} = delete $tests->{flavor_class}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# test count |
74
|
8
|
|
|
|
|
19
|
my $count = 2; |
75
|
8
|
|
|
|
|
28
|
$count += scalar(@{ $tests->{dirs} }); |
|
8
|
|
|
|
|
25
|
|
76
|
8
|
|
|
|
|
16
|
for my $test (@{ $tests->{files} }) { |
|
8
|
|
|
|
|
26
|
|
77
|
67
|
|
|
|
|
64
|
$count++; |
78
|
67
|
100
|
|
|
|
155
|
if (ref($test) eq 'HASH') { |
79
|
19
|
|
|
|
|
26
|
$count += @{ $test->{likes} }; |
|
19
|
|
|
|
|
51
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
8
|
|
|
|
|
46
|
plan tests => $count; |
84
|
8
|
|
|
|
|
38
|
module_setup $options, $module; |
85
|
|
|
|
|
|
|
|
86
|
8
|
|
|
|
|
53
|
my $base_path = context->distribute->dist_path; |
87
|
8
|
|
|
|
|
65
|
ok -d $base_path, 'base_path'; |
88
|
|
|
|
|
|
|
|
89
|
8
|
|
|
|
|
110
|
my %files = map { $_ => 1 } File::Find::Rule->new->relative->in( context->distribute->dist_path ); |
|
113
|
|
|
|
|
1566
|
|
90
|
|
|
|
|
|
|
|
91
|
8
|
|
|
|
|
64
|
for my $path (@{ $tests->{dirs} }) { |
|
8
|
|
|
|
|
73
|
|
92
|
18
|
100
|
|
|
|
304
|
Carp::croak "$path directory was missing" unless $files{$path}; |
93
|
17
|
|
|
|
|
94
|
my $dir = $base_path->subdir( split '/', $path ); |
94
|
17
|
|
|
|
|
467
|
ok -d $dir, "dir: $dir"; |
95
|
17
|
|
|
|
|
106
|
delete $files{$path}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
7
|
|
|
|
|
18
|
for my $data (@{ $tests->{files} }) { |
|
7
|
|
|
|
|
32
|
|
99
|
67
|
|
|
|
|
115
|
my $likes = []; |
100
|
67
|
|
|
|
|
115
|
my $path = $data; |
101
|
67
|
100
|
|
|
|
180
|
if (ref($data) eq 'HASH') { |
102
|
19
|
|
|
|
|
50
|
$path = $data->{file}; |
103
|
19
|
|
|
|
|
41
|
$likes = $data->{likes}; |
104
|
|
|
|
|
|
|
} |
105
|
67
|
100
|
|
|
|
643
|
Carp::croak "$path file was missing" unless $files{$path}; |
106
|
66
|
|
|
|
|
913
|
my $file = $base_path->file( split '/', $path ); |
107
|
66
|
|
|
|
|
2276
|
ok -f $file, "file: $file"; |
108
|
|
|
|
|
|
|
|
109
|
66
|
100
|
|
|
|
295
|
if (@{ $likes }) { |
|
66
|
|
|
|
|
183
|
|
110
|
19
|
|
|
|
|
85
|
my $slurp = $file->slurp; |
111
|
19
|
|
|
|
|
4491
|
for my $re (@{ $likes }) { |
|
19
|
|
|
|
|
54
|
|
112
|
23
|
|
|
|
|
117
|
like $slurp, $re, "like $re"; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
66
|
|
|
|
|
395
|
delete $files{$path}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
6
|
|
|
|
|
21
|
my $is_ok = !scalar(keys %files); |
120
|
6
|
|
|
|
|
23
|
ok $is_ok, "is all ok"; |
121
|
6
|
100
|
|
|
|
24
|
unless ($is_ok) { |
122
|
2
|
|
|
|
|
6
|
my $files = join ', ', keys %files; |
123
|
2
|
|
|
|
|
354
|
Carp::croak "missing tests for $files"; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
4
|
|
|
|
|
439
|
return 1; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 NAME |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Module::Setup::Test::Flavor - Test for flavor |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|