Test-Bomb
view release on metacpan or search on metacpan
lib/Test/Bomb.pm view on Meta::CPAN
our $VERSION = 0.007;
use Exporter qw/import/;
use Date::Parse;
use Test::More;
our @EXPORT = qw/ bomb /;
my @configFiles = (
$ENV{TESTBOMBCONFIG} || '',
'./t/tbc', './t/testbombconfig',
'./.tbc', './.testbombconfig',
'./tbc', './testbombconfig',
($ENV{HOME}||'.').'/.tbc',
($ENV{HOME}||'.').'/.testbombconfig',
);
%Test::Bomb::groups = ( );
lib/Test/Bomb.pm view on Meta::CPAN
this is a list of filenames where the test will look
to find bomb groups. File format is:
name=date
all whitespace is ignored. everything on the matching line is used
for the test. Non-matching lines are ignored.
The first file found is used, the first file checked is the environment
variable TESTBOMBCONFIG followed by [.]tbc and [.]testbombconfig in various
places
=item %groups
This variable allow groups to be assigned programatically.
Just assign hash element for the name of the group like this:
$Test::Bomb::group{DateCalculations} = 'Jan 1, 2000'; # RIP Y2K :)
Probably inside some module included by each test script so that they
use Test::Tester;
use Test::More;
# required to config file testing
BEGIN {
$Test::Bomb::cf = '/tmp/testTimeBomb';
$ENV{TESTBOMBCONFIG} = $Test::Bomb::cf;
use_ok 'Test::Bomb';
}
my $configFile = $Test::Bomb::cf;
my $earlyTime = localtime( time - 5000 );
my $lateTime = localtime(time + 5000 );
=head NOTE
check_test(
sub { bomb -with => 'bob' },
{ ok => 0, name => 'deadline passed', diag => '' },
'bomb group expired',
);
=item test config hash; bomb waiting
=cut
unlink $ENV{TESTBOMBCONFIG};
$Test::Bomb::groups{tom} = $lateTime;
check_test(
sub { bomb -with => 'tom' },
{ ok => 1, name => 'bomb after ' . $lateTime, diag => '' },
'hash:bomb group waiting',
);
=item test config hash; bomb expired
( run in 0.734 second using v1.01-cache-2.11-cpan-131fc08a04b )