@@ -26,11 +26,11 @@ Test2::Aggregate - Aggregate tests for increased speed
26
26
27
27
=head1 VERSION
28
28
29
- Version 0.17
29
+ Version 0.18
30
30
31
31
=cut
32
32
33
- our $VERSION = ' 0.17 ' ;
33
+ our $VERSION = ' 0.18 ' ;
34
34
35
35
=head1 DESCRIPTION
36
36
@@ -565,47 +565,66 @@ disable warnings on redefines only for tests that run aggregated:
565
565
Another idea is to make the test die when it is run under the aggregator, if, at
566
566
design time, you know it is not supposed to run aggregated.
567
567
568
+ =head2 agg helper script
569
+
570
+ agg [options] <file/dir ...>
571
+
572
+ Pass a list of Perl test files/directories and they will run aggregated via yath
573
+ (or prove if specified).
574
+
575
+ Options:
576
+ --out <s>, -o <s> : Specify the test file to be created (tmp file by default).
577
+ --prove, -p : Force prove (default is yath if detected).
578
+ --verbose, -v : Verbose (passed to yath/prove)
579
+ --include <s>, -I <s> : Library paths to include.
580
+ --test_warnings, -w : Fail tests on warnings.
581
+ --test_bundle <s>, -t : Test bundle (default: Test2::V0). Can be comma-separated list.
582
+ --pass_list <s>, -l <s> : Output directory for list of 100% passing tests.
583
+ --stats_output <s>, -s <s> : Stats output directory (does not combine with pass_list).
584
+ --help -h : Show basic help and exit.
585
+
568
586
=head2 Example aggregating strategy
569
587
570
588
There are many approaches you could do to use C<Test2::Aggregate > with an existing
571
- test suite, so for example you can start by making a list of the test files you
572
- are trying to aggregate:
589
+ test suite, usually involving an iterative process of trying to run several tests
590
+ aggregated, seeing if you can fix the failing ones, otherwise you remove them from
591
+ the aggregation etc.
573
592
574
- find t -name '*.t' > all.lst
593
+ This process can be done with the help of the C<agg > script. For example, to try
594
+ all tests under C<t/ > aggregated and a list of passing tests put under the C<pass >
595
+ directory you would do:
575
596
576
- If you have a substantial test suite, perhaps try with a portion of it (a subdir?)
577
- instead of the entire suite. In any case, try running them aggregated like this:
597
+ > agg -p pass t
578
598
579
- use Test2::Aggregate;
580
- use Test2::V0; # Or Test::More;
599
+ If the run completes, you have a "starting point" - i.e. a .txt list that can run
600
+ under the aggregator with the C< lists > option:
581
601
582
- my $stats = Test2::Aggregate::run_tests(
583
- lists => ['all.lst'],
602
+ Test2::Aggregate::run_tests(
603
+ lists => ['pass/name_of_file.txt']
584
604
);
585
605
586
- open OUT, ">pass.lst";
587
- foreach my $test (sort {$stats->{$a}->{test_no} <=> $stats->{$b}->{test_no}} keys %$stats) {
588
- print OUT "$test\n" if $stats->{$test}->{pass_perc};
589
- }
590
- close OUT;
591
-
592
- done_testing();
606
+ If the run does not complete, try fewer tests by choosing just a subdirectory. If
607
+ that's not possible, you'll probably have to go to the more manual method of getting
608
+ a full list of your tests (C<find t -name '*.t' E<gt> all.lst>) then trying to run
609
+ parts of it, again with the C<lists > option.
593
610
594
- Run the above with C<prove > or C<yath > in verbose mode, so that in case the run
595
- hangs (it can happen), you can see where it did so and edit C<all.lst > removing
596
- the offending test.
597
-
598
- If the run completes, you have a "starting point" - i.e. a list that can run under
599
- the aggregator in C<pass.lst > .
600
- You can try adding back some of the failed tests - test failures can be cascading,
601
- so some might be passing if added back, or have small issues you can address.
611
+ After you have a starting point, you can try see if there is an obvious reason some
612
+ tests fail and address it to add them back to the pass list. You can even try adding
613
+ back some of the failed tests that were not among the first to fail - test failures
614
+ can sometimes be cascading, so some might be passing if added back, or have small
615
+ issues you can address.
602
616
603
617
Try adding C<test_warnings =E<gt> 1> to C<run_tests > to fix warnings as well, unless
604
618
it is common for your tests to have C<STDERR > output.
605
619
606
- To have your entire suite run aggregated tests together once and not repeat them
607
- along with the other, non-aggregated, tests, it is a good idea to use the
608
- C<--exclude-list > option of the C<Test2::Harness > .
620
+ In the end, you will end up with part of your tests aggregated in (multiple if you
621
+ want to run them in parallel) list files, with the rest of your tests to be run
622
+ non-aggregated.
623
+
624
+ You don't actually have to move and separate aggregated/non-aggregated files when
625
+ using lists, you can still have your entire suite run the aggregated tests once and
626
+ not repeat them along with the other, non-aggregated tests, by taking advantage of
627
+ the C<--exclude-list > option of the C<Test2::Harness > .
609
628
610
629
Hopefully your tests can run in parallel (C<prove/yath -j > ), in which case you
611
630
would split your aggregated tests into multiple lists to have them run in parallel.
0 commit comments