line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
15
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Test::CompanionClasses::Engine; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
27
|
$Test::CompanionClasses::Engine::VERSION = '1.101370'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Run tests defined in companion classes |
10
|
1
|
|
|
1
|
|
1052
|
use FindBin '$Bin'; |
|
1
|
|
|
|
|
1013
|
|
|
1
|
|
|
|
|
102
|
|
11
|
1
|
|
|
1
|
|
4
|
use File::Find; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
12
|
1
|
|
|
1
|
|
989
|
use Test::More; |
|
1
|
|
|
|
|
17492
|
|
|
1
|
|
|
|
|
10
|
|
13
|
1
|
|
|
1
|
|
1210
|
use UNIVERSAL::require; |
|
1
|
|
|
|
|
1736
|
|
|
1
|
|
|
|
|
12
|
|
14
|
1
|
|
|
1
|
|
777
|
use parent 'Class::Accessor::Complex'; |
|
1
|
|
|
|
|
270
|
|
|
1
|
|
|
|
|
7
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_new; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub run_tests { |
18
|
1
|
|
|
1
|
1
|
46
|
my ($self, %args) = @_; |
19
|
1
|
50
|
|
|
|
3
|
our $package_filter = join '|' => map { "\Q$_\E" } @{ $args{filter} || [] }; |
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
8
|
|
20
|
1
|
50
|
|
|
|
8
|
$package_filter = "^($package_filter)\$" if $args{exact}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# default uses lib/ one level up, as the program using this class usually |
23
|
|
|
|
|
|
|
# lives in t/ |
24
|
1
|
|
33
|
|
|
13
|
my $lib = $args{lib} || "$Bin/../lib"; |
25
|
0
|
|
|
|
|
0
|
my @test_packages = |
26
|
0
|
0
|
|
|
|
0
|
map { { real_package => $_, test_package => $_ . '_TEST', } } |
27
|
1
|
50
|
|
|
|
14
|
grep { $package_filter ? m/$package_filter/ : 1 } |
28
|
1
|
|
|
|
|
11
|
@{ $args{inherited} || [] }; |
29
|
|
|
|
|
|
|
find( |
30
|
|
|
|
|
|
|
sub { |
31
|
7
|
100
|
100
|
7
|
|
421
|
return unless -f && /_TEST\.pm$/; |
32
|
1
|
|
|
|
|
2
|
my $test_package; |
33
|
1
|
50
|
|
|
|
31
|
if ($File::Find::name =~ m!\Q$lib\E/(.*_TEST)\.pm$!) { |
34
|
1
|
|
|
|
|
9
|
($test_package = $1) =~ s!/!::!g; |
35
|
|
|
|
|
|
|
} else { |
36
|
0
|
|
|
|
|
0
|
die "can't determine package from filename [$File::Find::name]"; |
37
|
|
|
|
|
|
|
} |
38
|
1
|
|
|
|
|
7
|
(my $real_package = $test_package) =~ s/_TEST$//; |
39
|
1
|
50
|
33
|
|
|
6
|
return if $package_filter && ($real_package !~ $package_filter); |
40
|
1
|
|
|
|
|
11
|
push @test_packages => { |
41
|
|
|
|
|
|
|
real_package => $real_package, |
42
|
|
|
|
|
|
|
test_package => $test_package, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
}, |
45
|
1
|
|
|
|
|
214
|
$lib |
46
|
|
|
|
|
|
|
); |
47
|
1
|
|
|
|
|
14
|
plan tests => scalar @test_packages; |
48
|
1
|
|
|
|
|
663
|
for (@test_packages) { |
49
|
|
|
|
|
|
|
subtest $_->{test_package}, sub { |
50
|
1
|
|
|
1
|
|
886
|
$_->{test_package}->require; |
51
|
1
|
50
|
|
|
|
15
|
die $@ if $@; |
52
|
1
|
|
|
|
|
12
|
plan tests => $_->{test_package}->planned_test_count; |
53
|
1
|
|
|
|
|
395
|
$_->{test_package}->new('package' => $_->{real_package})->run; |
54
|
1
|
|
|
|
|
13
|
}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |