| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- Mode: cperl; cperl-indent-level: 4 -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Test::Run::Core_GplArt; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4655
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
34
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
100
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Test::Run::Core_GplArt - GPL/Artistic-licensed code of Test::Run::Core. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Test::Run::Obj; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $tester = Test::Run::Obj->new({'test_files' => \@test_files}); |
|
17
|
|
|
|
|
|
|
$tester->runtests(); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
B<STOP!> If all you want to do is write a test script, consider |
|
22
|
|
|
|
|
|
|
using Test::Simple. Test::Run::Core is the module that reads the |
|
23
|
|
|
|
|
|
|
output from Test::Simple, Test::More and other modules based on |
|
24
|
|
|
|
|
|
|
Test::Builder. You don't need to know about Test::Run::Core to use |
|
25
|
|
|
|
|
|
|
those modules. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Test::Run::Core runs tests and expects output from the test in a |
|
28
|
|
|
|
|
|
|
certain format. That format is called TAP, the Test Anything |
|
29
|
|
|
|
|
|
|
Protocol. It is defined in L<Test::Harness::TAP>. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
C<$tester->runtests()> runs all the testscripts named |
|
32
|
|
|
|
|
|
|
as arguments and checks standard output for the expected strings |
|
33
|
|
|
|
|
|
|
in TAP format. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
L<Test::Run::Obj> is an applicative derived class of Test::Run::Core |
|
36
|
|
|
|
|
|
|
that provides a programmer API for running and analyzing the output of TAP |
|
37
|
|
|
|
|
|
|
files. For calling from the command line, look at |
|
38
|
|
|
|
|
|
|
L<Test::Run::CmdLine>. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 Taint mode |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Test::Run will honor the C<-T> or C<-t> in the #! line on your |
|
43
|
|
|
|
|
|
|
test files. So if you begin a test with: |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#!perl -T |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
the test will be run with taint mode on. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 Failure |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
When tests fail, analyze the summary report: |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
t/base..............ok |
|
55
|
|
|
|
|
|
|
t/nonumbers.........ok |
|
56
|
|
|
|
|
|
|
t/ok................ok |
|
57
|
|
|
|
|
|
|
t/test-harness......ok |
|
58
|
|
|
|
|
|
|
t/waterloo..........dubious |
|
59
|
|
|
|
|
|
|
Test returned status 3 (wstat 768, 0x300) |
|
60
|
|
|
|
|
|
|
DIED. FAILED tests 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 |
|
61
|
|
|
|
|
|
|
Failed 10/20 tests, 50.00% okay |
|
62
|
|
|
|
|
|
|
Failed Test Stat Wstat Total Fail Failed List of Failed |
|
63
|
|
|
|
|
|
|
----------------------------------------------------------------------- |
|
64
|
|
|
|
|
|
|
t/waterloo.t 3 768 20 10 50.00% 1 3 5 7 9 11 13 15 17 19 |
|
65
|
|
|
|
|
|
|
Failed 1/5 test scripts, 80.00% okay. 10/44 subtests failed, 77.27% okay. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Everything passed but F<t/waterloo.t>. It failed 10 of 20 tests and |
|
68
|
|
|
|
|
|
|
exited with non-zero status indicating something dubious happened. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The columns in the summary report mean: |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item B<Failed Test> |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The test file which failed. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B<Stat> |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
If the test exited with non-zero, this is its exit status. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B<Wstat> |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The wait status of the test. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B<Total> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Total number of tests expected to run. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item B<Fail> |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Number which failed, either from "not ok" or because they never ran. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item B<Failed> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Percentage of the total tests which failed. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item B<List of Failed> |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
A list of the tests which failed. Successive failures may be |
|
101
|
|
|
|
|
|
|
abbreviated (ie. 15-20 to indicate that tests 15, 16, 17, 18, 19 and |
|
102
|
|
|
|
|
|
|
20 failed). |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 Functions |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Test::Run currently only has one interface function, here it is. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item B<runtests> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $allok = $self->runtests(); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This runs all the given I<@test_files> and divines whether they passed |
|
118
|
|
|
|
|
|
|
or failed based on their output to STDOUT (details above). It prints |
|
119
|
|
|
|
|
|
|
out each individual test which failed along with a summary report and |
|
120
|
|
|
|
|
|
|
a how long it all took. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
It returns true if everything was ok. Otherwise it will C<die()> with |
|
123
|
|
|
|
|
|
|
one of the messages in the DIAGNOSTICS section. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=begin _private |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item B<_run_all_tests> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my($total, $failed) = _run_all_tests(); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Runs all the test_files defined for the object but does it |
|
134
|
|
|
|
|
|
|
quietly (no report). $total is a hash ref summary of all the tests |
|
135
|
|
|
|
|
|
|
run. Its keys and values are this: |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
bonus Number of individual todo tests unexpectedly passed |
|
138
|
|
|
|
|
|
|
max Number of individual tests ran |
|
139
|
|
|
|
|
|
|
ok Number of individual tests passed |
|
140
|
|
|
|
|
|
|
sub_skipped Number of individual tests skipped |
|
141
|
|
|
|
|
|
|
todo Number of individual todo tests |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
files Number of test files ran |
|
144
|
|
|
|
|
|
|
good Number of test files passed |
|
145
|
|
|
|
|
|
|
bad Number of test files failed |
|
146
|
|
|
|
|
|
|
tests Number of test files originally given |
|
147
|
|
|
|
|
|
|
skipped Number of test files skipped |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
If C<< $total->{bad} == 0 >> and C<< $total->{max} > 0 >>, you've |
|
150
|
|
|
|
|
|
|
got a successful test. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
$failed is a hash ref of all the test scripts which failed. Each key |
|
153
|
|
|
|
|
|
|
is the name of a test script, each value is another hash representing |
|
154
|
|
|
|
|
|
|
how that script failed. Its keys are these: |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
name Name of the test which failed |
|
157
|
|
|
|
|
|
|
estat Script's exit value |
|
158
|
|
|
|
|
|
|
wstat Script's wait status |
|
159
|
|
|
|
|
|
|
max Number of individual tests |
|
160
|
|
|
|
|
|
|
failed Number which failed |
|
161
|
|
|
|
|
|
|
percent Percentage of tests which failed |
|
162
|
|
|
|
|
|
|
canon List of tests which failed (as string). |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
C<$failed> should be empty if everything passed. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
B<NOTE> Currently this function is still noisy. I'm working on it. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=end _private |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
|
178
|
|
|
|
|
|
|
__END__ |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 EXPORT |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
None. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over 4 |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item C<All tests successful.\nFiles=%d, Tests=%d, %s> |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
If all tests are successful some statistics about the performance are |
|
192
|
|
|
|
|
|
|
printed. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item C<FAILED tests %s\n\tFailed %d/%d tests, %.2f%% okay.> |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
For any single script that has failing subtests statistics like the |
|
197
|
|
|
|
|
|
|
above are printed. |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item C<Test returned status %d (wstat %d)> |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Scripts that return a non-zero exit status, both C<$? E<gt>E<gt> 8> |
|
202
|
|
|
|
|
|
|
and C<$?> are printed in a message similar to the above. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item C<Failed 1 test, %.2f%% okay. %s> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item C<Failed %d/%d tests, %.2f%% okay. %s> |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
If not all tests were successful, the script dies with one of the |
|
209
|
|
|
|
|
|
|
above messages. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item C<FAILED--Further testing stopped: %s> |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
If a single subtest decides that further testing will not make sense, |
|
214
|
|
|
|
|
|
|
the script dies with this message. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 ENVIRONMENT VARIABLES THAT TEST::HARNESS SETS |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Test::Run sets these before executing the individual tests. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=over 4 |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item C<HARNESS_ACTIVE> |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This is set to a true value. It allows the tests to determine if they |
|
227
|
|
|
|
|
|
|
are being executed through the harness or by any other means. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item C<HARNESS_VERSION> |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This is the version of Test::Run. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=back |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
TODO: FIXME |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Here's how Test::Run tests itself |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
$ cd ~/src/devel/Test-Harness |
|
242
|
|
|
|
|
|
|
$ perl -Mblib -e 'use Test::Run qw(&runtests $verbose); |
|
243
|
|
|
|
|
|
|
$verbose=0; runtests @ARGV;' t/*.t |
|
244
|
|
|
|
|
|
|
Using /home/schwern/src/devel/Test-Harness/blib |
|
245
|
|
|
|
|
|
|
t/base..............ok |
|
246
|
|
|
|
|
|
|
t/nonumbers.........ok |
|
247
|
|
|
|
|
|
|
t/ok................ok |
|
248
|
|
|
|
|
|
|
t/test-harness......ok |
|
249
|
|
|
|
|
|
|
All tests successful. |
|
250
|
|
|
|
|
|
|
Files=4, Tests=24, 2 wallclock secs ( 0.61 cusr + 0.41 csys = 1.02 CPU) |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
The included F<prove> utility for running test scripts from the command line, |
|
255
|
|
|
|
|
|
|
L<Test> and L<Test::Simple> for writing test scripts, L<Benchmark> for |
|
256
|
|
|
|
|
|
|
the underlying timing routines, and L<Devel::Cover> for test coverage |
|
257
|
|
|
|
|
|
|
analysis. |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 TODO |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Provide a way of running tests quietly (ie. no printing) for automated |
|
262
|
|
|
|
|
|
|
validation of tests. This will probably take the form of a version |
|
263
|
|
|
|
|
|
|
of runtests() which rather than printing its output returns raw data |
|
264
|
|
|
|
|
|
|
on the state of the tests. (Partially done in Test::Run::Straps) |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Document the format. |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Fix HARNESS_COMPILE_TEST without breaking its core usage. |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Figure a way to report test names in the failure summary. |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Rework the test summary so long test names are not truncated as badly. |
|
273
|
|
|
|
|
|
|
(Partially done with new skip test styles) |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Add option for coverage analysis. |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Trap STDERR. |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Implement Straps total_results() |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Remember exit code |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
Completely redo the print summary code. |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Implement Straps callbacks. (experimentally implemented) |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Straps->analyze_file() not taint clean, don't know if it can be |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Fix that damned VMS nit. |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
HARNESS_TODOFAIL to display TODO failures |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Add a test for verbose. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Change internal list of test results to a hash. |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Fix stats display when there's an overrun. |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Fix so perls with spaces in the filename work. |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Keeping whittling away at _run_all_tests() |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Clean up how the summary is printed. Get rid of those damned formats. |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 BUGS |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
HARNESS_COMPILE_TEST currently assumes it's run from the Perl source |
|
308
|
|
|
|
|
|
|
directory. |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Please use the CPAN bug ticketing system at L<http://rt.cpan.org/>. |
|
311
|
|
|
|
|
|
|
You can also mail bugs, fixes and enhancements to |
|
312
|
|
|
|
|
|
|
C<< <bug-test-harness >> at C<< rt.cpan.org> >>. |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
Copyright 2002-2005 |
|
319
|
|
|
|
|
|
|
by Michael G Schwern C<< <schwern at pobox.com> >>, |
|
320
|
|
|
|
|
|
|
Andy Lester C<< <andy at petdance.com> >>. |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
|
323
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
See L<http://www.perl.com/perl/misc/Artistic.html>. |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=cut |