| 1 |
# |
| 2 |
# what happens if Time::HiRes is not available ? |
| 3 |
# |
| 4 |
#BEGIN { # use this for a fake Time::HiRes |
| 5 |
# unshift @INC, sub { |
| 6 |
# my (undef, $what) = @_; |
| 7 |
# print "include -> $what\n"; |
| 8 |
# return if $what ne 'Time/HiRes.pm'; |
| 9 |
# open my $fh, '<', 't/1cover/no-time-hires.t' or die "open: $!"; |
| 10 |
# while (my $junk = <$fh>) { |
| 11 |
# $junk =~ s/[\r\n]+$//g; #chomp |
| 12 |
# last if $junk eq '__DA'.'TA__'; |
| 13 |
# } |
| 14 |
# return \'', $fh; |
| 15 |
# }; |
| 16 |
#} |
| 17 |
use strict; |
| 18 |
use warnings; |
| 19 |
BEGIN { |
| 20 |
# need to pre-load modules used |
| 21 |
# everywhere else EXCEPT Time::HiRes |
| 22 |
require vars; |
| 23 |
require constant; |
| 24 |
require Exporter; |
| 25 |
require Carp; |
| 26 |
require DynaLoader; |
| 27 |
require File::Temp; |
| 28 |
#require Time::HiRes; |
| 29 |
local @INC = ( 't/0LIB', @INC ); |
| 30 |
require MyTest; # this requires UUID if note() or diag() called, so dont do that |
| 31 |
MyTest::pass('loaded'); |
| 32 |
} |
| 33 |
|
| 34 |
MyTest::pass('running'); |
| 35 |
|
| 36 |
eval { |
| 37 |
local @INC = qw(blib/lib blib/arch); |
| 38 |
require UUID; |
| 39 |
}; |
| 40 |
if ($@ =~ /Time::HiRes is required/) { |
| 41 |
MyTest::pass('died as expected'); |
| 42 |
} |
| 43 |
elsif ($@ ne '') { |
| 44 |
my $e = $@; |
| 45 |
chomp $e; |
| 46 |
my @lines = split $/, $e; |
| 47 |
MyTest::fail('died with wrong error'); |
| 48 |
print "# $_\n" for @lines; |
| 49 |
} |
| 50 |
else { |
| 51 |
MyTest::fail('did not die'); |
| 52 |
} |
| 53 |
|
| 54 |
MyTest::done_testing(); |