line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Badger::Test; |
2
|
|
|
|
|
|
|
|
3
|
70
|
|
|
70
|
|
82387
|
use Carp; |
|
70
|
|
|
|
|
387
|
|
|
70
|
|
|
|
|
5597
|
|
4
|
70
|
|
|
70
|
|
23213
|
use Badger; |
|
70
|
|
|
|
|
202
|
|
|
70
|
|
|
|
|
609
|
|
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
|
|
|
|
|
625
|
map { $_ => \&_export_hook } |
|
350
|
|
|
|
|
1522
|
|
21
|
|
|
|
|
|
|
qw( summary colour color args tests ) |
22
|
|
|
|
|
|
|
}, |
23
|
70
|
|
|
70
|
|
500
|
}; |
|
70
|
|
|
|
|
153
|
|
24
|
|
|
|
|
|
|
|
25
|
70
|
|
|
70
|
|
553
|
use Badger::Debug; |
|
70
|
|
|
|
|
213
|
|
|
70
|
|
|
|
|
425
|
|
26
|
70
|
|
|
70
|
|
505
|
use Badger::Exception; |
|
70
|
|
|
|
|
130
|
|
|
70
|
|
|
|
|
1051
|
|
27
|
70
|
|
|
70
|
|
33466
|
use Badger::Test::Manager; |
|
70
|
|
|
|
|
3414
|
|
|
70
|
|
|
|
|
18822
|
|
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
|
|
17
|
Badger->lib($_[3]); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _skip_hook { |
41
|
3
|
|
|
3
|
|
13
|
$MANAGER->skip_all($_[3]); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _if_env_hook { |
45
|
2
|
|
|
2
|
|
4
|
my $vars = $_[3]; |
46
|
2
|
50
|
|
|
|
21
|
$IF_ENV = $vars eq ARRAY |
47
|
|
|
|
|
|
|
? $vars |
48
|
|
|
|
|
|
|
: [ split(DELIMITER, $vars) ] |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _export_hook { |
52
|
126
|
|
|
126
|
|
743
|
my ($class, $target, $key, $symbols) = @_; |
53
|
126
|
50
|
|
|
|
382
|
croak "You didn't specify a value for the '$key' load option" |
54
|
|
|
|
|
|
|
unless @$symbols; |
55
|
126
|
|
|
|
|
514
|
$class->$key(shift @$symbols); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _debug_hook { |
59
|
64
|
|
|
64
|
|
214
|
my ($class, $target, $key, $symbols, $import) = @_; |
60
|
64
|
50
|
|
|
|
361
|
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
|
|
711
|
no strict 'refs'; |
|
70
|
|
|
|
|
287
|
|
|
70
|
|
|
|
|
88233
|
|
66
|
64
|
|
|
|
|
141
|
*{ $target.PKG.DEBUG } = \$DEBUG; |
|
64
|
|
|
|
|
531
|
|
67
|
64
|
|
|
0
|
|
298
|
*{ $target.PKG.DEBUG } = sub { $DEBUG }; |
|
64
|
|
|
|
|
282
|
|
|
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
|
|
|
|
|
153
|
my $modules = shift @$symbols; |
72
|
64
|
50
|
|
|
|
232
|
return unless $modules; # zero/false for no debugging |
73
|
64
|
|
|
|
|
213
|
$class->debug_modules($modules); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _after_hook { |
77
|
98
|
|
|
98
|
|
240
|
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
|
|
|
479
|
if ($IF_ENV && ! $ALL) { |
84
|
2
|
|
|
|
|
4
|
my $run = 0; |
85
|
2
|
|
|
|
|
4
|
my @names = @$IF_ENV; |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
6
|
foreach my $var (@names) { |
88
|
3
|
100
|
|
|
|
11
|
$run++, last if $ENV{$var}; |
89
|
|
|
|
|
|
|
} |
90
|
2
|
100
|
|
|
|
7
|
unless ($run) { |
91
|
1
|
|
|
|
|
1
|
my $name = pop(@names); |
92
|
1
|
|
|
|
|
3
|
$name = join(' or ', join(', ', @names), $name); |
93
|
1
|
|
|
|
|
12
|
$MANAGER->skip_all("Tests only apply for $name"); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub manager { |
99
|
1807
|
|
|
1807
|
1
|
2350
|
my $class = shift; |
100
|
|
|
|
|
|
|
return @_ |
101
|
1807
|
50
|
|
|
|
6970
|
? ($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
|
137
|
my $self = shift; |
117
|
67
|
50
|
33
|
|
|
686
|
my $args = @_ && ref $_[0] eq ARRAY ? shift : [ @_ ]; |
118
|
67
|
|
|
|
|
154
|
my $arg; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# quick hack until Badger::Config is done |
121
|
67
|
|
33
|
|
|
485
|
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
|
116
|
shift; |
153
|
59
|
|
|
|
|
254
|
plan(@_); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub debug_modules { |
157
|
64
|
|
|
64
|
1
|
128
|
my $self = shift; |
158
|
64
|
|
|
|
|
303
|
$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
|
|
269
|
plan => sub ($;$) { manager->plan(@_) }, |
194
|
514
|
|
|
514
|
|
13189
|
ok => sub ($;$) { manager->ok(@_) }, |
195
|
1157
|
|
|
1157
|
|
8958
|
is => sub ($$;$) { manager->is(@_) }, |
196
|
5
|
|
|
5
|
|
21
|
isnt => sub ($$;$) { manager->isnt(@_) }, |
197
|
41
|
|
|
41
|
|
869
|
like => sub ($$;$) { manager->like(@_) }, |
198
|
2
|
|
|
2
|
|
24
|
unlike => sub ($$;$) { manager->unlike(@_) }, |
199
|
22
|
|
|
22
|
|
214
|
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
|
|
366
|
skip_all => sub (;$) { manager->skip_all(@_) }, |
205
|
|
|
|
|
|
|
); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
1; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
__END__ |