5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
9 plan tests => 6 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
13 'App/Codeowners/Options.pm',
14 'App/Codeowners/Util.pm',
16 'Test/File/Codeowners.pm'
23 # no fake home requested
26 -d 'blib' ? '-Mblib' : '-Ilib',
33 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
36 for my $lib (@module_files)
38 # see L<perlfaq8/How can I capture STDERR from an external command?>
39 my $stderr = IO::Handle->new;
41 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
42 $^X, @switches, '-e', "require q[$lib]"))
43 if $ENV{PERL_COMPILE_TEST_DEBUG};
45 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
46 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
47 my @_warnings = <$stderr>;
49 is($?, 0, "$lib loaded ok");
51 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
52 and not eval { +require blib; blib->VERSION('1.01') };
57 push @warnings, @_warnings;
61 foreach my $file (@scripts)
63 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
66 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
67 @switches = (@switches, split(' ', $1)) if $1;
69 close $fh and skip("$file uses -T; not testable with PERL5LIB", 1)
70 if grep { $_ eq '-T' } @switches and $ENV{PERL5LIB};
72 my $stderr = IO::Handle->new;
74 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
75 $^X, @switches, '-c', $file))
76 if $ENV{PERL_COMPILE_TEST_DEBUG};
78 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
79 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
80 my @_warnings = <$stderr>;
82 is($?, 0, "$file compiled ok");
84 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
85 and not eval { +require blib; blib->VERSION('1.01') };
87 # in older perls, -c output is simply the file portion of the path being tested
88 if (@_warnings = grep { !/\bsyntax OK$/ }
89 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
92 push @warnings, @_warnings;
98 is(scalar(@warnings), 0, 'no warnings found')
99 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};