Debian Codegraph @

t/00-compile.t

raw
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 => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
9
10 my @module_files = (
11 'CPAN/Perl/Releases.pm'
12 );
13
14
15
16 # no fake home requested
17
18 my @switches = (
19 -d 'blib' ? '-Mblib' : '-Ilib',
20 );
21
22 use File::Spec;
23 use IPC::Open3;
24 use IO::Handle;
25
26 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
27
28 my @warnings;
29 for my $lib (@module_files)
30 {
31 # see L<perlfaq8/How can I capture STDERR from an external command?>
32 my $stderr = IO::Handle->new;
33
34 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'}.$str.q{'} }
35 $^X, @switches, '-e', "require q[$lib]"))
36 if $ENV{PERL_COMPILE_TEST_DEBUG};
37
38 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
39 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
40 my @_warnings = <$stderr>;
41 waitpid($pid, 0);
42 is($?, 0, "$lib loaded ok");
43
44 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
45 and not eval { +require blib; 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') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
57
58