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