| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package TAP::Runner::Test; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$TAP::Runner::Test::VERSION = '0.005'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Runner test class |
|
6
|
1
|
|
|
1
|
|
1629
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
|
8
|
|
|
|
|
|
|
use TAP::Runner::Option; |
|
9
|
|
|
|
|
|
|
use Math::Cartesian::Product; # Used for cartesian multiplication |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
subtype 'ArrayRef::' . __PACKAGE__, |
|
12
|
|
|
|
|
|
|
as 'ArrayRef[' . __PACKAGE__ . ']'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
coerce 'ArrayRef::' . __PACKAGE__, |
|
15
|
|
|
|
|
|
|
from 'ArrayRef[HashRef]', |
|
16
|
|
|
|
|
|
|
via { [ map { __PACKAGE__->new($_) } @{$_} ] }; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has file => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
isa => 'Str', |
|
21
|
|
|
|
|
|
|
required => 1, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has alias => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => 'Str', |
|
27
|
|
|
|
|
|
|
lazy_build => 1, |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has args => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
33
|
|
|
|
|
|
|
default => sub{ [] }, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has options => ( |
|
37
|
|
|
|
|
|
|
is => 'ro', |
|
38
|
|
|
|
|
|
|
isa => 'ArrayRef::TAP::Runner::Option', |
|
39
|
|
|
|
|
|
|
default => sub{ [] }, |
|
40
|
|
|
|
|
|
|
coerce => 1, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has harness_tests => ( |
|
44
|
|
|
|
|
|
|
is => 'ro', |
|
45
|
|
|
|
|
|
|
isa => 'ArrayRef[HashRef]', |
|
46
|
|
|
|
|
|
|
lazy_build => 1, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_parallel_rules { |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
my @rules = (); |
|
53
|
|
|
|
|
|
|
my @parallel_options = |
|
54
|
|
|
|
|
|
|
grep { $_->multiple && $_->parallel } @{ $self->options }; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
foreach my $option ( @parallel_options ) { |
|
57
|
|
|
|
|
|
|
my $test_alias = $self->alias; |
|
58
|
|
|
|
|
|
|
my $option_name = $option->name; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
push @rules, { seq => qr/$test_alias.*$option_name $_.*$/ } |
|
61
|
|
|
|
|
|
|
foreach @{ $option->values }; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
( @rules ); |
|
65
|
|
|
|
|
|
|
}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Build alias if it not defined |
|
68
|
|
|
|
|
|
|
sub _build_alias { |
|
69
|
|
|
|
|
|
|
my $self = shift; |
|
70
|
|
|
|
|
|
|
$self->file; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Build harness tests list from all the options and args |
|
74
|
|
|
|
|
|
|
sub _build_harness_tests { |
|
75
|
|
|
|
|
|
|
my $self = shift; |
|
76
|
|
|
|
|
|
|
my @multiple_options = (); |
|
77
|
|
|
|
|
|
|
my @harness_tests = (); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Array of args that same for all the tests |
|
80
|
|
|
|
|
|
|
my @test_args = @{ $self->args }; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
foreach my $option ( @{ $self->options } ) { |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
if ( $option->multiple ) { |
|
85
|
|
|
|
|
|
|
push @multiple_options, $option; |
|
86
|
|
|
|
|
|
|
next; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Add options that same for all the tests |
|
90
|
|
|
|
|
|
|
push @test_args, map { ( $option->name, $_ ) } @{ $option->values }; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# If there are multiple options, that should passed to tests, build correct |
|
95
|
|
|
|
|
|
|
# tests args and harness tests |
|
96
|
|
|
|
|
|
|
if ( @multiple_options ) { |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Make array of arrays that contains merged options values with it names |
|
99
|
|
|
|
|
|
|
# Example: |
|
100
|
|
|
|
|
|
|
# ( |
|
101
|
|
|
|
|
|
|
# [ [ opt_name1, opt_val1.1 ], [ opt_name1, opt_val1.2 ] ], |
|
102
|
|
|
|
|
|
|
# [ [ opt_name2, opt_val2.1 ], [ opt_name2, opt_val2.2 ] ], |
|
103
|
|
|
|
|
|
|
# ) |
|
104
|
|
|
|
|
|
|
# |
|
105
|
|
|
|
|
|
|
my @merged_options = map { $_->get_values_array } @multiple_options; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Make cartesian multiplication with all options |
|
108
|
|
|
|
|
|
|
# Result of example multiplication: |
|
109
|
|
|
|
|
|
|
# [ opt_name1, opt_val1.1 ],[ opt_name2, opt_val2.1 ] |
|
110
|
|
|
|
|
|
|
# [ opt_name1, opt_val1.1 ],[ opt_name2, opt_val2.2 ] |
|
111
|
|
|
|
|
|
|
# [ opt_name1, opt_val1.2 ],[ opt_name2, opt_val2.1 ] |
|
112
|
|
|
|
|
|
|
# [ opt_name1, opt_val1.2 ],[ opt_name2, opt_val2.2 ] |
|
113
|
|
|
|
|
|
|
# |
|
114
|
|
|
|
|
|
|
cartesian { |
|
115
|
|
|
|
|
|
|
# Unmerge options make separated option name and value |
|
116
|
|
|
|
|
|
|
# Example: ( opt_name1, opt_val1, opt_name2, opt_val2 ) |
|
117
|
|
|
|
|
|
|
my @opt_args = map { ($_->[0],$_->[1]) } @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Build new alias defends on options that passed to test |
|
120
|
|
|
|
|
|
|
my $alias = $self->alias .' '. join(' ',@opt_args); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
push @harness_tests, { |
|
123
|
|
|
|
|
|
|
file => $self->file, |
|
124
|
|
|
|
|
|
|
alias => $alias, |
|
125
|
|
|
|
|
|
|
args => [ @test_args, @opt_args ], |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
} @merged_options; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} else { |
|
130
|
|
|
|
|
|
|
push @harness_tests, { |
|
131
|
|
|
|
|
|
|
file => $self->file, |
|
132
|
|
|
|
|
|
|
alias => $self->alias, |
|
133
|
|
|
|
|
|
|
args => \@test_args, |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
\@harness_tests; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
no Moose; |
|
141
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
142
|
|
|
|
|
|
|
1; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=pod |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 NAME |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
TAP::Runner::Test - Runner test class |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 VERSION |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
version 0.005 |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Test object used by L<TAP::Runner> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 MOOSE SUBTYPES |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 ArrayRef::TAP::Runner::Test |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Coerce ArrayRef[HashRef] to ArrayRef[TAP::Runner::Option] Used by L<TAP::Runner> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 file Str |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Test file to run ( required ) |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 alias Str |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Alias for tests ( by default used file name ) |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 args ArrayRef |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Arguments that will pass to all the tests |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 options ArrayRef[TAP::Runner::Option] |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Array of L<TAP::Runner::Option> used by test. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 harness_tests ArrayRef[HashRef] |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Array of hashes prepared for testing with L<TAP::Harness> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
HashRef -> { file: file.t, alias: 'Test alias', args: [] } |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 METHODS |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 get_parallel_rules |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Rules for run tests in parallel |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Pavel R3VoLuT1OneR Zhytomirsky <r3volut1oner@gmail.com> |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Pavel R3VoLuT1OneR Zhytomirsky. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
205
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
__END__ |