From: Graham Knop Date: Sun, 1 Jun 2014 05:57:49 +0000 (-0400) Subject: better testing of extra module load failures X-Git-Tag: v1.999_001~1^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c7063c9bce905f3146305267492ce4b49a73c76;p=p5sagit%2Fstrictures.git better testing of extra module load failures --- diff --git a/t/crash.t b/t/crash.t index 5134293..4aebc1c 100644 --- a/t/crash.t +++ b/t/crash.t @@ -1,16 +1,29 @@ -use strictures; +use strict; +use warnings FATAL => 'all'; +use Test::More + $] < 5.008004 ? ( skip_all => "can't test extra loading on perl < 5.8.4" ) + : ( tests => 1 ); +use File::Spec; -use Test::More tests => 1; +my %extras = map { my $m = "$_.pm"; $m =~ s{::}{/}g; $m => 1 } qw( + indirect + multidimensional + bareword::filehandles +); -SKIP: { - skip 'Have all the modules; can\'t check this', 1 - unless not eval { - require indirect; - require multidimensional; - require bareword::filehandles; - 1; - }; +unshift @INC, sub { + my $mod = $_[1]; + die "Can't locate $mod in \@INC\n" + if $extras{$mod}; + return 0; +}; - pass('can manage to survive with some modules missing!'); -} +my $err = do { + local $ENV{PERL_STRICTURES_EXTRA} = 1; + local *STDERR; + open STDERR, '>', File::Spec->devnull; + eval q{use strictures;}; + $@; +}; +is $err, '', 'can manage to survive with some modules missing!';