line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
126
|
use v5.12.0; |
|
10
|
|
|
|
|
35
|
|
2
|
|
|
|
|
|
|
package Test::Routine::Runner 0.030; |
3
|
|
|
|
|
|
|
# ABSTRACT: tools for running Test::Routine tests |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
1673
|
use Moose; |
|
10
|
|
|
|
|
953731
|
|
|
10
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#pod =head1 OVERVIEW |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod A Test::Routine::Runner takes a callback for building test instances, then uses |
10
|
|
|
|
|
|
|
#pod it to build instances and run the tests on it. The Test::Routine::Runner |
11
|
|
|
|
|
|
|
#pod interface is still undergoing work, but the Test::Routine::Util exports for |
12
|
|
|
|
|
|
|
#pod running tests, described in L<Test::Routine|Test::Routine/Running Tests>, are |
13
|
|
|
|
|
|
|
#pod more stable. Please use those instead, unless you are willing to deal with |
14
|
|
|
|
|
|
|
#pod interface breakage. |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod =cut |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
71126
|
use Carp qw(confess croak); |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
1972
|
|
19
|
10
|
|
|
10
|
|
80
|
use Scalar::Util qw(reftype); |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
579
|
|
20
|
10
|
|
|
10
|
|
1703
|
use Test2::API 1.302045 (); |
|
10
|
|
|
|
|
143701
|
|
|
10
|
|
|
|
|
252
|
|
21
|
10
|
|
|
10
|
|
59
|
use Try::Tiny; |
|
10
|
|
|
|
|
1201
|
|
|
10
|
|
|
|
|
2880
|
|
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
10
|
|
75
|
use Moose::Util::TypeConstraints; |
|
10
|
|
|
|
|
67
|
|
|
10
|
|
|
|
|
104
|
|
24
|
|
|
|
|
|
|
|
25
|
10
|
|
|
10
|
|
22930
|
use namespace::clean; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
72
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
subtype 'Test::Routine::_InstanceBuilder', as 'CodeRef'; |
28
|
|
|
|
|
|
|
subtype 'Test::Routine::_Instance', |
29
|
|
|
|
|
|
|
as 'Object', |
30
|
|
|
|
|
|
|
where { $_->does('Test::Routine::Common') }; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
coerce 'Test::Routine::_InstanceBuilder', |
33
|
|
|
|
|
|
|
from 'Test::Routine::_Instance', |
34
|
|
|
|
|
|
|
via { my $instance = $_; sub { $instance } }; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has _instance_builder => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => 'Test::Routine::_InstanceBuilder', |
39
|
|
|
|
|
|
|
coerce => 1, |
40
|
|
|
|
|
|
|
traits => [ 'Code' ], |
41
|
|
|
|
|
|
|
init_arg => 'instance_from', |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
handles => { |
44
|
|
|
|
|
|
|
'build_test_instance' => 'execute_method', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has description => ( |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
isa => 'Str', |
51
|
|
|
|
|
|
|
required => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub run { |
55
|
21
|
|
|
21
|
0
|
58
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
|
57
|
21
|
|
|
|
|
859
|
my $test_instance = $self->build_test_instance; |
58
|
|
|
|
|
|
|
|
59
|
21
|
|
|
|
|
186
|
my @tests = grep { Moose::Util::does_role($_, 'Test::Routine::Test::Role') } |
|
394
|
|
|
|
|
44174
|
|
60
|
|
|
|
|
|
|
$test_instance->meta->get_all_methods; |
61
|
|
|
|
|
|
|
|
62
|
21
|
|
|
|
|
1576
|
my $re = $ENV{TEST_METHOD}; |
63
|
21
|
100
|
|
|
|
80
|
if (length $re) { |
64
|
3
|
|
|
3
|
|
168
|
my $filter = try { qr/$re/ } # compile the the regex separately ... |
65
|
3
|
|
|
0
|
|
26
|
catch { croak("TEST_METHOD ($re) is not a valid regular expression: $_") }; |
|
0
|
|
|
|
|
0
|
|
66
|
3
|
|
|
|
|
96
|
$filter = qr/\A$filter\z/; # ... so it can't mess with the anchoring |
67
|
3
|
|
|
|
|
12
|
@tests = grep { $_->description =~ $filter } @tests; |
|
12
|
|
|
|
|
325
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# As a side note, I wonder whether there is any way to format the code below |
71
|
|
|
|
|
|
|
# to not look stupid. -- rjbs, 2010-09-28 |
72
|
|
|
|
|
|
|
my @ordered_tests = sort { |
73
|
21
|
|
|
|
|
121
|
$a->_origin->{file} cmp $b->_origin->{file} |
74
|
|
|
|
|
|
|
|| $a->_origin->{nth} <=> $b->_origin->{nth} |
75
|
29
|
0
|
|
|
|
853
|
} @tests; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Test2::API::run_subtest($self->description, sub { |
78
|
21
|
|
|
21
|
|
17433
|
TEST: for my $test (@ordered_tests) { |
79
|
45
|
|
|
|
|
857
|
my $ctx = Test2::API::context; |
80
|
45
|
100
|
|
|
|
4161
|
if (my $reason = $test->skip_reason($test_instance)) { |
81
|
3
|
|
|
|
|
443
|
$ctx->skip($test->name, $reason); |
82
|
|
|
|
|
|
|
} else { |
83
|
42
|
|
|
|
|
586
|
$test_instance->run_test( $test ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
45
|
|
|
|
|
2451
|
$ctx->release; |
87
|
|
|
|
|
|
|
} |
88
|
21
|
|
|
|
|
607
|
}); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=encoding UTF-8 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Test::Routine::Runner - tools for running Test::Routine tests |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
version 0.030 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 OVERVIEW |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
A Test::Routine::Runner takes a callback for building test instances, then uses |
110
|
|
|
|
|
|
|
it to build instances and run the tests on it. The Test::Routine::Runner |
111
|
|
|
|
|
|
|
interface is still undergoing work, but the Test::Routine::Util exports for |
112
|
|
|
|
|
|
|
running tests, described in L<Test::Routine|Test::Routine/Running Tests>, are |
113
|
|
|
|
|
|
|
more stable. Please use those instead, unless you are willing to deal with |
114
|
|
|
|
|
|
|
interface breakage. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 PERL VERSION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
119
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
120
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
121
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
124
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
125
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
126
|
|
|
|
|
|
|
the minimum required perl. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Ricardo Signes. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |