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