| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Badger::Test; |
|
2
|
|
|
|
|
|
|
|
|
3
|
70
|
|
|
70
|
|
79413
|
use Carp; |
|
|
70
|
|
|
|
|
354
|
|
|
|
70
|
|
|
|
|
5387
|
|
|
4
|
70
|
|
|
70
|
|
22376
|
use Badger; |
|
|
70
|
|
|
|
|
200
|
|
|
|
70
|
|
|
|
|
557
|
|
|
5
|
|
|
|
|
|
|
use Badger::Class |
|
6
|
|
|
|
|
|
|
version => 0.01, |
|
7
|
|
|
|
|
|
|
base => 'Badger::Base', |
|
8
|
|
|
|
|
|
|
import => 'CLASS class', |
|
9
|
|
|
|
|
|
|
constants => 'ARRAY DELIMITER PKG', |
|
10
|
|
|
|
|
|
|
words => 'DEBUG DEBUG_MODULES', |
|
11
|
|
|
|
|
|
|
exports => { |
|
12
|
|
|
|
|
|
|
all => 'plan ok is isnt like unlike pass fail |
|
13
|
|
|
|
|
|
|
skip_some skip_rest skip_all manager', |
|
14
|
|
|
|
|
|
|
after => \&_after_hook, |
|
15
|
|
|
|
|
|
|
hooks => { |
|
16
|
|
|
|
|
|
|
lib => [\&_lib_hook, 1], |
|
17
|
|
|
|
|
|
|
skip => [\&_skip_hook, 1], |
|
18
|
|
|
|
|
|
|
if_env => [\&_if_env_hook, 1], |
|
19
|
|
|
|
|
|
|
debug => \&_debug_hook, |
|
20
|
70
|
|
|
|
|
593
|
map { $_ => \&_export_hook } |
|
|
350
|
|
|
|
|
1853
|
|
|
21
|
|
|
|
|
|
|
qw( summary colour color args tests ) |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
70
|
|
|
70
|
|
485
|
}; |
|
|
70
|
|
|
|
|
149
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
70
|
|
|
70
|
|
566
|
use Badger::Debug; |
|
|
70
|
|
|
|
|
214
|
|
|
|
70
|
|
|
|
|
405
|
|
|
26
|
70
|
|
|
70
|
|
505
|
use Badger::Exception; |
|
|
70
|
|
|
|
|
170
|
|
|
|
70
|
|
|
|
|
1048
|
|
|
27
|
70
|
|
|
70
|
|
32066
|
use Badger::Test::Manager; |
|
|
70
|
|
|
|
|
3160
|
|
|
|
70
|
|
|
|
|
18588
|
|
|
28
|
|
|
|
|
|
|
our $MANAGER = 'Badger::Test::Manager'; |
|
29
|
|
|
|
|
|
|
our $DEBUGGER = 'Badger::Debug'; |
|
30
|
|
|
|
|
|
|
our $EXCEPTION = 'Badger::Exception'; |
|
31
|
|
|
|
|
|
|
our ($ALL, $IF_ENV, $DEBUG, $DEBUG_MODULES); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
*color = \&colour; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _lib_hook { |
|
37
|
3
|
|
|
3
|
|
16
|
Badger->lib($_[3]); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _skip_hook { |
|
41
|
3
|
|
|
3
|
|
26
|
$MANAGER->skip_all($_[3]); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _if_env_hook { |
|
45
|
2
|
|
|
2
|
|
5
|
my $vars = $_[3]; |
|
46
|
2
|
50
|
|
|
|
25
|
$IF_ENV = $vars eq ARRAY |
|
47
|
|
|
|
|
|
|
? $vars |
|
48
|
|
|
|
|
|
|
: [ split(DELIMITER, $vars) ] |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _export_hook { |
|
52
|
126
|
|
|
126
|
|
319
|
my ($class, $target, $key, $symbols) = @_; |
|
53
|
126
|
50
|
|
|
|
308
|
croak "You didn't specify a value for the '$key' load option" |
|
54
|
|
|
|
|
|
|
unless @$symbols; |
|
55
|
126
|
|
|
|
|
481
|
$class->$key(shift @$symbols); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _debug_hook { |
|
59
|
64
|
|
|
64
|
|
201
|
my ($class, $target, $key, $symbols, $import) = @_; |
|
60
|
64
|
50
|
|
|
|
293
|
croak "You didn't specify any values for the 'debug' load option.\n" |
|
61
|
|
|
|
|
|
|
unless @$symbols; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# define $DEBUG in caller |
|
65
|
70
|
|
|
70
|
|
707
|
no strict 'refs'; |
|
|
70
|
|
|
|
|
288
|
|
|
|
70
|
|
|
|
|
84134
|
|
|
66
|
64
|
|
|
|
|
118
|
*{ $target.PKG.DEBUG } = \$DEBUG; |
|
|
64
|
|
|
|
|
397
|
|
|
67
|
64
|
|
|
0
|
|
288
|
*{ $target.PKG.DEBUG } = sub { $DEBUG }; |
|
|
64
|
|
|
|
|
201
|
|
|
|
0
|
|
|
|
|
0
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# set $DEBUG_MODULE in this class to contain the argument passed - a list |
|
70
|
|
|
|
|
|
|
# of class names to enable $DEBUG in when/if debugging is enabled |
|
71
|
64
|
|
|
|
|
152
|
my $modules = shift @$symbols; |
|
72
|
64
|
50
|
|
|
|
289
|
return unless $modules; # zero/false for no debugging |
|
73
|
64
|
|
|
|
|
240
|
$class->debug_modules($modules); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _after_hook { |
|
77
|
98
|
|
|
98
|
|
236
|
my ($class, $target) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# See if we've got any constraints specified and assert that they're |
|
80
|
|
|
|
|
|
|
# met. If the --all command line parameter is specified (which sets |
|
81
|
|
|
|
|
|
|
# $ALL) then we run the tests regardless |
|
82
|
|
|
|
|
|
|
|
|
83
|
98
|
100
|
66
|
|
|
445
|
if ($IF_ENV && ! $ALL) { |
|
84
|
2
|
|
|
|
|
3
|
my $run = 0; |
|
85
|
2
|
|
|
|
|
12
|
my @names = @$IF_ENV; |
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
5
|
foreach my $var (@names) { |
|
88
|
3
|
100
|
|
|
|
20
|
$run++, last if $ENV{$var}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
2
|
100
|
|
|
|
7
|
unless ($run) { |
|
91
|
1
|
|
|
|
|
2
|
my $name = pop(@names); |
|
92
|
1
|
|
|
|
|
4
|
$name = join(' or ', join(', ', @names), $name); |
|
93
|
1
|
|
|
|
|
5
|
$MANAGER->skip_all("Tests only apply for $name"); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub manager { |
|
99
|
1807
|
|
|
1807
|
1
|
2283
|
my $class = shift; |
|
100
|
|
|
|
|
|
|
return @_ |
|
101
|
1807
|
50
|
|
|
|
6423
|
? ($MANAGER = shift) |
|
102
|
|
|
|
|
|
|
: $MANAGER; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub colour { |
|
106
|
0
|
|
|
0
|
1
|
0
|
shift; |
|
107
|
0
|
|
|
|
|
0
|
manager->colour(@_); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub summary { |
|
111
|
0
|
|
|
0
|
1
|
0
|
shift; |
|
112
|
0
|
|
|
|
|
0
|
manager->summary(@_); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub args { |
|
116
|
67
|
|
|
67
|
1
|
170
|
my $self = shift; |
|
117
|
67
|
50
|
33
|
|
|
641
|
my $args = @_ && ref $_[0] eq ARRAY ? shift : [ @_ ]; |
|
118
|
67
|
|
|
|
|
147
|
my $arg; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# quick hack until Badger::Config is done |
|
121
|
67
|
|
33
|
|
|
570
|
while (@$args && $args->[0] =~ /^-/) { |
|
122
|
0
|
|
|
|
|
0
|
$arg = shift @$args; |
|
123
|
0
|
0
|
|
|
|
0
|
if ($arg =~ /^(-c|--colou?r)$/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
$self->colour(1); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
elsif ($arg =~ /^(-d|--debug)$/) { |
|
127
|
|
|
|
|
|
|
# physically set $DEBUG in this package (required for exported |
|
128
|
|
|
|
|
|
|
# aliases) and also call debugging() for any subclasses to use |
|
129
|
0
|
|
|
|
|
0
|
$self->debugging( $DEBUG = 1 ); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
elsif ($arg =~ /^(-s|--summary)$/) { |
|
132
|
0
|
|
|
|
|
0
|
$self->summary(1); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
elsif ($arg =~ /^(-t|--trace)$/) { |
|
135
|
0
|
|
|
|
|
0
|
$self->trace(1); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
elsif ($arg =~ /^(-a|--all)$/) { |
|
138
|
0
|
|
|
|
|
0
|
$self->all(1); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
elsif ($arg =~ /^(-h|--help)$/) { |
|
141
|
0
|
|
|
|
|
0
|
warn $self->help; |
|
142
|
0
|
|
|
|
|
0
|
exit; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
else { |
|
145
|
0
|
|
|
|
|
0
|
unshift(@$args, $arg); |
|
146
|
0
|
|
|
|
|
0
|
last; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub tests { |
|
152
|
59
|
|
|
59
|
1
|
105
|
shift; |
|
153
|
59
|
|
|
|
|
200
|
plan(@_); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub debug_modules { |
|
157
|
64
|
|
|
64
|
1
|
124
|
my $self = shift; |
|
158
|
64
|
|
|
|
|
263
|
$self->class->var( DEBUG_MODULES => shift ); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub debugging { |
|
162
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
163
|
0
|
0
|
|
|
|
0
|
my $flag = $DEBUG = (@_ ? shift : 1); |
|
164
|
0
|
|
0
|
|
|
0
|
my $modules = $self->class->var(DEBUG_MODULES) || return; |
|
165
|
0
|
|
|
|
|
0
|
$DEBUGGER->debug_modules($modules); |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub trace { |
|
169
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
170
|
0
|
0
|
|
|
|
0
|
my $flag = @_ ? shift : 1; |
|
171
|
0
|
|
|
|
|
0
|
$EXCEPTION->trace($flag); |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub all { |
|
175
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
176
|
0
|
0
|
|
|
|
0
|
$ALL = @_ ? shift : 1; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub help { |
|
180
|
0
|
|
|
0
|
1
|
0
|
return <
|
|
181
|
|
|
|
|
|
|
Options: |
|
182
|
|
|
|
|
|
|
-a --all Run all tests (e.g. author/release tests) |
|
183
|
|
|
|
|
|
|
-d --debug Enable debugging |
|
184
|
|
|
|
|
|
|
-t --trace Enable stack tracing |
|
185
|
|
|
|
|
|
|
-c --colour/--color Enable colour output |
|
186
|
|
|
|
|
|
|
-s --summary Display summary of test results |
|
187
|
|
|
|
|
|
|
-h --help This help summary |
|
188
|
|
|
|
|
|
|
END_OF_HELP |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
class->methods( |
|
193
|
62
|
|
|
62
|
|
289
|
plan => sub ($;$) { manager->plan(@_) }, |
|
194
|
514
|
|
|
514
|
|
12386
|
ok => sub ($;$) { manager->ok(@_) }, |
|
195
|
1157
|
|
|
1157
|
|
6744
|
is => sub ($$;$) { manager->is(@_) }, |
|
196
|
5
|
|
|
5
|
|
19
|
isnt => sub ($$;$) { manager->isnt(@_) }, |
|
197
|
41
|
|
|
41
|
|
745
|
like => sub ($$;$) { manager->like(@_) }, |
|
198
|
2
|
|
|
2
|
|
18
|
unlike => sub ($$;$) { manager->unlike(@_) }, |
|
199
|
22
|
|
|
22
|
|
176
|
pass => sub (;$) { manager->pass(@_) }, |
|
200
|
0
|
|
|
0
|
|
0
|
fail => sub (;$) { manager->fail(@_) }, |
|
201
|
0
|
|
|
0
|
|
0
|
skip => sub (;$) { manager->skip(@_) }, |
|
202
|
0
|
|
|
0
|
|
0
|
skip_some => sub (;$$) { manager->skip_some(@_) }, |
|
203
|
0
|
|
|
0
|
|
0
|
skip_rest => sub (;$) { manager->skip_rest(@_) }, |
|
204
|
4
|
|
|
4
|
|
432
|
skip_all => sub (;$) { manager->skip_all(@_) }, |
|
205
|
|
|
|
|
|
|
); |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
1; |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
__END__ |