| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
|
| 4 |
# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.059 |
| 5 |
|
| 6 |
use Test::More; |
| 7 |
|
| 8 |
plan tests => 3; |
| 9 |
|
| 10 |
my @module_files = ( |
| 11 |
'CPAN/Meta/Requirements.pm', |
| 12 |
'CPAN/Meta/Requirements/Range.pm' |
| 13 |
); |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
# fake home for cpan-testers |
| 18 |
use File::Temp; |
| 19 |
local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); |
| 20 |
|
| 21 |
|
| 22 |
my @switches = ( |
| 23 |
-d 'blib' ? '-Mblib' : '-Ilib', |
| 24 |
); |
| 25 |
|
| 26 |
use File::Spec; |
| 27 |
use IPC::Open3; |
| 28 |
use IO::Handle; |
| 29 |
|
| 30 |
open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; |
| 31 |
|
| 32 |
my @warnings; |
| 33 |
for my $lib (@module_files) |
| 34 |
{ |
| 35 |
# see L<perlfaq8/How can I capture STDERR from an external command?> |
| 36 |
my $stderr = IO::Handle->new; |
| 37 |
|
| 38 |
diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'}.$str.q{'} } |
| 39 |
$^X, @switches, '-e', "require q[$lib]")) |
| 40 |
if $ENV{PERL_COMPILE_TEST_DEBUG}; |
| 41 |
|
| 42 |
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); |
| 43 |
binmode $stderr, ':crlf' if $^O eq 'MSWin32'; |
| 44 |
my @_warnings = <$stderr>; |
| 45 |
waitpid($pid, 0); |
| 46 |
is($?, 0, "$lib loaded ok"); |
| 47 |
|
| 48 |
shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ |
| 49 |
and not eval { +require blib; blib->VERSION('1.01') }; |
| 50 |
|
| 51 |
if (@_warnings) |
| 52 |
{ |
| 53 |
warn @_warnings; |
| 54 |
push @warnings, @_warnings; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); |
| 61 |
|
| 62 |
|