@@ -19,7 +19,7 @@ Test2::Aggregate - Aggregate tests for increased speed
19
19
use Test2::V0; # Or 'use Test::More' etc if your suite uses an other framework
20
20
21
21
Test2::Aggregate::run_tests(
22
- dirs => \@test_dirs
22
+ dirs => [@test_dirs_or_files]
23
23
);
24
24
25
25
done_testing();
@@ -76,12 +76,14 @@ have less issues with L<Test2::Suite> (see notes).
76
76
unique => 1, # optional
77
77
repeat => 1, # optional, requires Test2::Plugin::BailOnFail for < 0
78
78
slow => 0, # optional
79
+ test_warnings => 0, # optional
79
80
override => \%override, # optional, requires Sub::Override
80
81
stats_output => $stats_output_path, # optional
81
82
extend_stats => 0, # optional
82
83
pass_only => 0, # optional
83
84
absolute => 0, # optional
84
- test_warnings => 0, # optional
85
+ bail_on_fail => 0, # optional, requires Test2::Plugin::BailOnFail
86
+ no_dot => 0, # optional
85
87
allow_errors => 0, # optional
86
88
pre_eval => $code_to_eval, # optional
87
89
dry_run => 0, # optional
@@ -242,6 +244,12 @@ but still allow additions in future versions that will only be written with the
242
244
C<extend_stats > option enabled.
243
245
Additions with C<extend_stats > as of the current version:
244
246
247
+ =over 4
248
+
249
+ - starting date/time in ISO_8601.
250
+
251
+ =back
252
+
245
253
=item * C<pass_only > (optional)
246
254
247
255
Modifies C<stats_output > by making it only print out a list of passing tests.
@@ -252,11 +260,15 @@ Has no effect if C<stats_output> is not defined.
252
260
253
261
Matches pre-v0.18 behaviour by including C<root > to the output of stats.
254
262
255
- =over 4
263
+ =item * C< no_dot > (optional)
256
264
257
- - starting date/time in ISO_8601.
265
+ Current version will add a C<./ > at the start of a test file if the full path does
266
+ not start with C</ > or C<. > to avoid the C<'.' is no longer in @INC > error.
267
+ Setting C<no_dot > to true matches pre-v0.18 behaviour that did not do this.
258
268
259
- =back
269
+ =item * C<bail_on_fail > (optional)
270
+
271
+ Will bail (exit) on first test failure.
260
272
261
273
=back
262
274
@@ -320,6 +332,7 @@ sub run_tests {
320
332
}
321
333
}
322
334
} elsif ($args {test_warnings }) {
335
+ eval ' use Test2::Plugin::BailOnFail' if $args {bail_on_fail };
323
336
$warnings = _process_warnings(
324
337
Test2::V0::warnings { _run_tests(\@tests , \%args ) },
325
338
\%args
@@ -330,6 +343,7 @@ sub run_tests {
330
343
' No warnings in the aggregate tests.'
331
344
);
332
345
} else {
346
+ eval ' use Test2::Plugin::BailOnFail' if $args {bail_on_fail };
333
347
_run_tests(\@tests , \%args );
334
348
}
335
349
@@ -411,9 +425,12 @@ sub _run_tests {
411
425
if ($args -> {dry_run }) {
412
426
Test2::V0::ok($test );
413
427
} else {
428
+ my $t = $test ;
429
+ $t = " ./$test "
430
+ unless $args -> {no_dot } || $test =~ m # ^[./] # ;
414
431
$args -> {package }
415
- ? eval " package Test::$i " . ' ::' . " $count ; do '$test ';"
416
- : do $test ;
432
+ ? eval " package Test::$i " . ' ::' . " $count ; do '$t ';"
433
+ : do $t ;
417
434
$exec_error = $@ ;
418
435
}
419
436
Test2::V0::is($exec_error , ' ' , ' Execution should not fail/warn' )
@@ -482,6 +499,7 @@ sub _stats_fh {
482
499
my $file = $args -> {stats_output }." /" .$args -> {caller }." -" ._timestamp()." .txt" ;
483
500
open ($fh , ' >' , $file ) or die " Can't open > $file : $! " ;
484
501
}
502
+ select ($fh ); $| = 1; select (STDOUT );
485
503
486
504
$args -> {total_time } = 0;
487
505
my $extra = $args -> {extend_stats } ? ' TIMESTAMP' : ' ' ;
@@ -530,6 +548,36 @@ sub _timestamp {
530
548
return sprintf " %04d%02d%02dT%02d%02d%02d" , $Y +1900, $M +1, $D , $h , $m , $s ;
531
549
}
532
550
551
+ =head1 HELPER SCRIPTS
552
+
553
+ =head2 agg (Test2::Aggregate harness wrapper)
554
+
555
+ agg [options] <file/dir1 ...>
556
+
557
+ Pass a list of Perl test files/directories and they will run aggregated via yath
558
+ (or prove if specified). It is not meant to be used for .t files that use Test2::Aggregate
559
+ themselves.
560
+
561
+ It is useful either to speed up a test run for tests you know can be aggregated,
562
+ or to check whether specific tests can run successfully under Test2::Aggregate.
563
+
564
+ Options:
565
+ --out <s>, -o <s> : Specify the test file to be created (tmp file by default).
566
+ --lists, -l : Use files specified as lists.
567
+ --prove, -p : Force prove (default is yath/Test2 if installed).
568
+ --verbose, -v : Verbose (passed to yath/prove)
569
+ --absolute, -a : Use absolute paths in generated files. Disabled with -r.
570
+ --root <s> -r <s> : Define a custom root dir (default is current dir).
571
+ --include <s>, -I <s> : Library paths to include.
572
+ --test_warnings, -w : Fail tests on warnings.
573
+ --test_bundle <s>, -t : Test bundle (def: Test2::V0 or Test::More if -p). Can be comma-separated list.
574
+ --pass_output <s>, -po <s> : Output directory for list of 100% passing tests.
575
+ --reverse : Reverse the test order.
576
+ --shuffle : Shuffle the test order.
577
+ --sort : Run the tests alphabetically.
578
+ --stats_output <s>, -so <s> : Stats output directory (does not combine with pass_output).
579
+ --help -h : Show basic help and exit.
580
+
533
581
=head1 USAGE NOTES
534
582
535
583
Not all tests can be modified to run under the aggregator, it is not intended
@@ -613,29 +661,6 @@ disable warnings on redefines only for tests that run aggregated:
613
661
Another idea is to make the test die when it is run under the aggregator, if, at
614
662
design time, you know it is not supposed to run aggregated.
615
663
616
- =head2 agg helper script
617
-
618
- agg [options] <file/dir1 ...>
619
-
620
- Pass a list of Perl test files/directories and they will run aggregated via yath
621
- (or prove if specified).
622
-
623
- Options:
624
- --out <s>, -o <s> : Specify the test file to be created (tmp file by default).
625
- --lists, -l : Use files specified as lists.
626
- --prove, -p : Force prove (default is yath/Test2 if detected).
627
- --verbose, -v : Verbose (passed to yath/prove)
628
- --absolute, -a : Use absolute paths in generated files.
629
- --include <s>, -I <s> : Library paths to include.
630
- --test_warnings, -w : Fail tests on warnings.
631
- --test_bundle <s>, -t : Test bundle (def: Test2::V0 or Test::More if -p). Can be comma-separated list.
632
- --pass_output <s>, -po <s> : Output directory for list of 100% passing tests.
633
- --reverse : Reverse the test order.
634
- --shuffle : Shuffle the test order.
635
- --sort : Run the tests alphabetically.
636
- --stats_output <s>, -so <s> : Stats output directory (does not combine with pass_list).
637
- --help -h : Show basic help and exit.
638
-
639
664
=head2 Example aggregating strategy
640
665
641
666
There are many approaches you could do to use C<Test2::Aggregate > with an existing
0 commit comments