| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Routine::Runner; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: tools for running Test::Routine tests |
|
3
|
|
|
|
|
|
|
$Test::Routine::Runner::VERSION = '0.029'; |
|
4
|
10
|
|
|
10
|
|
1338
|
use Moose; |
|
|
10
|
|
|
|
|
813999
|
|
|
|
10
|
|
|
|
|
67
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#pod =head1 OVERVIEW |
|
7
|
|
|
|
|
|
|
#pod |
|
8
|
|
|
|
|
|
|
#pod A Test::Routine::Runner takes a callback for building test instances, then uses |
|
9
|
|
|
|
|
|
|
#pod it to build instances and run the tests on it. The Test::Routine::Runner |
|
10
|
|
|
|
|
|
|
#pod interface is still undergoing work, but the Test::Routine::Util exports for |
|
11
|
|
|
|
|
|
|
#pod running tests, described in L<Test::Routine|Test::Routine/Running Tests>, are |
|
12
|
|
|
|
|
|
|
#pod more stable. Please use those instead, unless you are willing to deal with |
|
13
|
|
|
|
|
|
|
#pod interface breakage. |
|
14
|
|
|
|
|
|
|
#pod |
|
15
|
|
|
|
|
|
|
#pod =cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
10
|
|
|
10
|
|
61070
|
use Carp qw(confess croak); |
|
|
10
|
|
|
|
|
24
|
|
|
|
10
|
|
|
|
|
1961
|
|
|
18
|
10
|
|
|
10
|
|
59
|
use Scalar::Util qw(reftype); |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
528
|
|
|
19
|
10
|
|
|
10
|
|
2497
|
use Test2::API 1.302045 (); |
|
|
10
|
|
|
|
|
122612
|
|
|
|
10
|
|
|
|
|
230
|
|
|
20
|
10
|
|
|
10
|
|
53
|
use Try::Tiny; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
581
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
10
|
|
|
10
|
|
67
|
use Moose::Util::TypeConstraints; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
2427
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
10
|
|
|
10
|
|
20596
|
use namespace::clean; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
75
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# XXX: THIS CODE BELOW WILL BE REMOVED VERY SOON -- rjbs, 2010-10-18 |
|
27
|
10
|
|
|
|
|
124
|
use Sub::Exporter -setup => { |
|
28
|
|
|
|
|
|
|
exports => [ |
|
29
|
|
|
|
|
|
|
run_tests => \'_curry_tester', |
|
30
|
|
|
|
|
|
|
run_me => \'_curry_tester', |
|
31
|
|
|
|
|
|
|
], |
|
32
|
|
|
|
|
|
|
groups => [ default => [ qw(run_me run_tests) ] ], |
|
33
|
10
|
|
|
10
|
|
5244
|
}; |
|
|
10
|
|
|
|
|
63
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _curry_tester { |
|
36
|
0
|
|
|
0
|
|
0
|
my ($class, $name) = @_; |
|
37
|
10
|
|
|
10
|
|
5257
|
use Test::Routine::Util; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
5755
|
|
|
38
|
0
|
|
|
|
|
0
|
my $sub = Test::Routine::Util->_curry_tester($name); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return sub { |
|
41
|
0
|
|
|
0
|
|
0
|
warn "you got $name from Test::Routine::Runner; use Test::Routine::Util instead; Test::Routine::Runner's exports will be removed soon\n"; |
|
42
|
0
|
|
|
|
|
0
|
goto &$sub; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
0
|
|
|
|
|
0
|
} |
|
45
|
|
|
|
|
|
|
# XXX: THIS CODE ABOVE WILL BE REMOVED VERY SOON -- rjbs, 2010-10-18 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
subtype 'Test::Routine::_InstanceBuilder', as 'CodeRef'; |
|
48
|
|
|
|
|
|
|
subtype 'Test::Routine::_Instance', |
|
49
|
|
|
|
|
|
|
as 'Object', |
|
50
|
|
|
|
|
|
|
where { $_->does('Test::Routine::Common') }; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
coerce 'Test::Routine::_InstanceBuilder', |
|
53
|
|
|
|
|
|
|
from 'Test::Routine::_Instance', |
|
54
|
|
|
|
|
|
|
via { my $instance = $_; sub { $instance } }; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has _instance_builder => ( |
|
57
|
|
|
|
|
|
|
is => 'ro', |
|
58
|
|
|
|
|
|
|
isa => 'Test::Routine::_InstanceBuilder', |
|
59
|
|
|
|
|
|
|
coerce => 1, |
|
60
|
|
|
|
|
|
|
traits => [ 'Code' ], |
|
61
|
|
|
|
|
|
|
init_arg => 'instance_from', |
|
62
|
|
|
|
|
|
|
required => 1, |
|
63
|
|
|
|
|
|
|
handles => { |
|
64
|
|
|
|
|
|
|
'build_test_instance' => 'execute_method', |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has description => ( |
|
69
|
|
|
|
|
|
|
is => 'ro', |
|
70
|
|
|
|
|
|
|
isa => 'Str', |
|
71
|
|
|
|
|
|
|
required => 1, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub run { |
|
75
|
21
|
|
|
21
|
0
|
73
|
my ($self) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
21
|
|
|
|
|
737
|
my $test_instance = $self->build_test_instance; |
|
78
|
|
|
|
|
|
|
|
|
79
|
21
|
|
|
|
|
169
|
my @tests = grep { Moose::Util::does_role($_, 'Test::Routine::Test::Role') } |
|
|
394
|
|
|
|
|
38263
|
|
|
80
|
|
|
|
|
|
|
$test_instance->meta->get_all_methods; |
|
81
|
|
|
|
|
|
|
|
|
82
|
21
|
|
|
|
|
1064
|
my $re = $ENV{TEST_METHOD}; |
|
83
|
21
|
100
|
100
|
|
|
97
|
if (defined $re and length $re) { |
|
84
|
3
|
|
|
3
|
|
160
|
my $filter = try { qr/$re/ } # compile the the regex separately ... |
|
85
|
3
|
|
|
0
|
|
30
|
catch { croak("TEST_METHOD ($re) is not a valid regular expression: $_") }; |
|
|
0
|
|
|
|
|
0
|
|
|
86
|
3
|
|
|
|
|
81
|
$filter = qr/\A$filter\z/; # ... so it can't mess with the anchoring |
|
87
|
3
|
|
|
|
|
11
|
@tests = grep { $_->description =~ $filter } @tests; |
|
|
12
|
|
|
|
|
274
|
|
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# As a side note, I wonder whether there is any way to format the code below |
|
91
|
|
|
|
|
|
|
# to not look stupid. -- rjbs, 2010-09-28 |
|
92
|
|
|
|
|
|
|
my @ordered_tests = sort { |
|
93
|
21
|
|
|
|
|
100
|
$a->_origin->{file} cmp $b->_origin->{file} |
|
94
|
|
|
|
|
|
|
|| $a->_origin->{nth} <=> $b->_origin->{nth} |
|
95
|
32
|
0
|
|
|
|
809
|
} @tests; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Test2::API::run_subtest($self->description, sub { |
|
98
|
21
|
|
|
21
|
|
27932
|
TEST: for my $test (@ordered_tests) { |
|
99
|
45
|
|
|
|
|
696
|
my $ctx = Test2::API::context; |
|
100
|
45
|
100
|
|
|
|
3751
|
if (my $reason = $test->skip_reason($test_instance)) { |
|
101
|
3
|
|
|
|
|
372
|
$ctx->skip($test->name, $reason); |
|
102
|
|
|
|
|
|
|
} else { |
|
103
|
42
|
|
|
|
|
556
|
$test_instance->run_test( $test ); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
45
|
|
|
|
|
2030
|
$ctx->release; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
21
|
|
|
|
|
553
|
}); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=pod |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=encoding UTF-8 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 NAME |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Test::Routine::Runner - tools for running Test::Routine tests |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 VERSION |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
version 0.029 |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 OVERVIEW |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
A Test::Routine::Runner takes a callback for building test instances, then uses |
|
130
|
|
|
|
|
|
|
it to build instances and run the tests on it. The Test::Routine::Runner |
|
131
|
|
|
|
|
|
|
interface is still undergoing work, but the Test::Routine::Util exports for |
|
132
|
|
|
|
|
|
|
running tests, described in L<Test::Routine|Test::Routine/Running Tests>, are |
|
133
|
|
|
|
|
|
|
more stable. Please use those instead, unless you are willing to deal with |
|
134
|
|
|
|
|
|
|
interface breakage. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 PERL VERSION |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
|
139
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
|
140
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
|
141
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
|
144
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
|
145
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
|
146
|
|
|
|
|
|
|
the minimum required perl. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Ricardo Signes. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |