Test::Aggregate - Aggregate *.t tests to make them run faster.
*.t
Version 0.02
use Test::Aggregate; Test::Aggregate->runtests($dir);
WARNING: this is ALPHA code. The interface is not guaranteed to be stable.
A common problem with many test suites is that they can take a long time to run. The longer they run, the less likely you are to run the tests. This module borrows a trick from Apache::Registry to load up your tests at once, create a separate package for each test and wraps the code in a method named run_the_tests. This allows us to load perl only once and related modules only once. If you have modules which are expensive to load, this can dramatically speed up a test suite.
Apache::Registry
run_the_tests
Create a separate directory for your tests. This should not be a subdirectory of your regular test directory. Write a small driver program and put it in your regular test directory (t/ is the standard):
t/
use Test::Aggregate; my $other_test_dir = 'aggregate_tests'; Test::Aggregate->runtests($other_test_dir);
Take your simplest tests and move them, one by one, into the new test directory and keep running the Test::Aggregate program. You'll find some tests will not run in a shared environment like this. You can either fix the tests or simply leave them in your regular test directory. See how this distribution's tests are organized for an example.
Test::Aggregate
runtests
my $test_dir = 'aggtests/'; Test::Aggregate->runtests($test_dir);
Attempts to aggregate all test programs in a given directory and run them at the same time.
If $Test::Aggregate::DUMP is set, will attempt to use the value as a filename and print the code to it.
$Test::Aggregate::DUMP
Not all tests can be included with this technique. If you have Test::Class tests, there is no need to run them with this. Otherwise:
Test::Class
__END__ and __DATA__ tokens.
__END__
__DATA__
These won't work and the tests will call BAIL_OUT() if these tokens are seen.
BEGIN and END blocks.
BEGIN
END
Since all of the tests are aggregated together, BEGIN and END blocks will be for the scope of the entire set of aggregated tests.
Syntax errors
Any syntax errors encountered will cause this program to BAIL_OUT(). This is why it's recommended that you move your tests into your new directory one at a time: it makes it easier to figure out which one has caused the problem.
no_plan
Unfortunately, due to how this works, the plan is always no_plan. If Test::Builder implements "deferred plans", we can get a bit more safety. See http://groups.google.com/group/perl.qa/browse_thread/thread/d58c49db734844f4/cd18996391acc601?#cd18996391acc601 for more information.
Test::Builder
Variable "$x" will not stay shared at (eval ...
Because each test is wrapped in a method call, any of your subs which access a variable in an outer scope will likely throw the above warning. Pass in arguments explicitly to suppress this.
Instead of:
my $x = 17; sub foo { my $y = shift; return $y + $x; }
Write this:
my $x = 17; sub foo { my ( $y, $x ) = @_; return $y + $x; }
Curtis Poe, <ovid at cpan.org>
<ovid at cpan.org>
Please report any bugs or feature requests to bug-test-aggregate at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Aggregate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-test-aggregate at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Test::Aggregate
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Test-Aggregate
CPAN Ratings
http://cpanratings.perl.org/d/Test-Aggregate
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Aggregate
Search CPAN
http://search.cpan.org/dist/Test-Aggregate
Copyright 2007 Curtis Poe, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Aggregate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Aggregate
CPAN shell
perl -MCPAN -e shell install Test::Aggregate
For more information on module installation, please visit the detailed CPAN module installation guide.