@@ -15,7 +15,7 @@ Test2::Aggregate - Aggregate tests for increased speed
15
15
16
16
=head1 VERSION
17
17
18
- Version 0.17
18
+ Version 0.18
19
19
20
20
=head1 DESCRIPTION
21
21
@@ -64,6 +64,7 @@ have less issues with L<Test2::Suite> (see notes).
64
64
override => \%override, # optional, requires Sub::Override
65
65
stats_output => $stats_output_path, # optional
66
66
extend_stats => 0, # optional
67
+ pass_only => 0, # optional
67
68
test_warnings => 0, # optional
68
69
allow_errors => 0, # optional
69
70
pre_eval => $code_to_eval, # optional
@@ -219,11 +220,17 @@ the output to C</dev/null>, C</tmp> etc).
219
220
220
221
=item * C<extend_stats> (optional)
221
222
222
- This option exists to make the default output format of C<stats_output> be fixed,
223
+ This option exist to make the default output format of C<stats_output> be fixed,
223
224
but still allow additions in future versions that will only be written with the
224
225
C<extend_stats> option enabled.
225
226
Additions with C<extend_stats> as of the current version:
226
227
228
+ =item * C<pass_only> (optional)
229
+
230
+ Modifies C<stats_output> by making it only print out a list of passing tests.
231
+ Useful for creating lists of aggregateable tests.
232
+ Has no effect if C<stats_output> is not defined.
233
+
227
234
=over 4
228
235
229
236
- starting date/time in ISO_8601.
@@ -315,47 +322,67 @@ disable warnings on redefines only for tests that run aggregated:
315
322
Another idea is to make the test die when it is run under the aggregator, if, at
316
323
design time, you know it is not supposed to run aggregated.
317
324
325
+ =head2 agg helper script
326
+
327
+ agg [options] <file/dir ...>
328
+
329
+ Pass a list of Perl test files/directories and they will run aggregated via yath
330
+ (or prove if specified).
331
+
332
+ Options:
333
+ --out <s>, -o <s> : Specify the test file to be created (tmp file by default).
334
+ --prove, -p : Force prove (default is yath if detected).
335
+ --verbose, -v : Verbose (passed to yath/prove)
336
+ --include <s>, -I <s> : Library paths to include.
337
+ --test_warnings, -w : Fail tests on warnings.
338
+ --test_bundle <s>, -t : Test bundle (default: Test2::V0). Can be comma-separated list.
339
+ --pass_list <s>, -l <s> : Output directory for list of 100% passing tests.
340
+ --stats_output <s>, -s <s> : Stats output directory (does not combine with pass_list).
341
+ --help -h : Show basic help and exit.
342
+
318
343
=head2 Example aggregating strategy
319
344
320
345
There are many approaches you could do to use C<Test2::Aggregate> with an existing
321
- test suite, so for example you can start by making a list of the test files you
322
- are trying to aggregate:
346
+ test suite, usually involving an iterative process of trying to run several tests
347
+ aggregated, seeing if you can fix the failing ones, otherwise you remove them from
348
+ the aggregation etc.
323
349
324
- find t -name '*.t' > all.lst
350
+ This process can be done with the help of the C<agg> script. For example, to try
351
+ all tests under C<t/> aggregated and a list of passing tests put under the C<pass>
352
+ directory you would do:
325
353
326
- If you have a substantial test suite, perhaps try with a portion of it (a subdir?)
327
- instead of the entire suite. In any case, try running them aggregated like this:
354
+ > agg -p pass t
328
355
329
- use Test2::Aggregate;
330
- use Test2::V0; # Or Test::More;
356
+ If the run completes, you have a "starting point" - i.e. a .txt list that can run
357
+ under the aggregator with the C<lists> option:
331
358
332
- my $stats = Test2::Aggregate::run_tests(
333
- lists => ['all.lst'],
359
+ Test2::Aggregate::run_tests(
360
+ lists => ['pass/name_of_file.txt']
334
361
);
335
362
336
- open OUT, ">pass.lst";
337
- foreach my $test (sort {$stats->{$a}->{test_no} <=> $stats->{$b}->{test_no}} keys %$stats) {
338
- print OUT "$test\n" if $stats->{$test}->{pass_perc};
339
- }
340
- close OUT;
341
-
342
- done_testing();
363
+ If the run does not complete (e.g. signal 11 on some test), try fewer tests by
364
+ choosing just a subdirectory. If that's not possible, you'll probably have to go
365
+ to the more manual method of getting a full list of your tests
366
+ (C<find t -name '*.t' E<gt> all.lst>) then trying to run parts of it, again with
367
+ the C<lists> option.
343
368
344
- Run the above with C<prove> or C<yath> in verbose mode, so that in case the run
345
- hangs (it can happen), you can see where it did so and edit C<all.lst> removing
346
- the offending test.
347
-
348
- If the run completes, you have a "starting point" - i.e. a list that can run under
349
- the aggregator in C<pass.lst>.
350
- You can try adding back some of the failed tests - test failures can be cascading,
351
- so some might be passing if added back, or have small issues you can address.
369
+ After you have a starting point, you can try see if there is an obvious reason some
370
+ tests fail and address it to add them back to the pass list. You can even try adding
371
+ back some of the failed tests that were not among the first to fail - test failures
372
+ can sometimes be cascading, so some might be passing if added back, or have small
373
+ issues you can address.
352
374
353
375
Try adding C<test_warnings =E<gt> 1> to C<run_tests> to fix warnings as well, unless
354
376
it is common for your tests to have C<STDERR> output.
355
377
356
- To have your entire suite run aggregated tests together once and not repeat them
357
- along with the other, non-aggregated, tests, it is a good idea to use the
358
- C<--exclude-list> option of the C<Test2::Harness>.
378
+ In the end, you will end up with part of your tests aggregated in (multiple if you
379
+ want to run them in parallel) list files, with the rest of your tests to be run
380
+ non-aggregated.
381
+
382
+ You don't actually have to move and separate aggregated/non-aggregated files when
383
+ using lists, you can still have your entire suite run the aggregated tests once and
384
+ not repeat them along with the other, non-aggregated tests, by taking advantage of
385
+ the C<--exclude-list> option of the C<Test2::Harness>.
359
386
360
387
Hopefully your tests can run in parallel (C<prove/yath -j>), in which case you
361
388
would split your aggregated tests into multiple lists to have them run in parallel.
0 commit comments