5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
9 plan tests => 13 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
13 'App/Codeowners/Formatter.pm',
14 'App/Codeowners/Formatter/CSV.pm',
15 'App/Codeowners/Formatter/JSON.pm',
16 'App/Codeowners/Formatter/String.pm',
17 'App/Codeowners/Formatter/TSV.pm',
18 'App/Codeowners/Formatter/Table.pm',
19 'App/Codeowners/Formatter/YAML.pm',
20 'App/Codeowners/Options.pm',
21 'App/Codeowners/Util.pm',
23 'Test/File/Codeowners.pm'
30 # no fake home requested
33 -d 'blib' ? '-Mblib' : '-Ilib',
40 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
43 for my $lib (@module_files)
45 # see L<perlfaq8/How can I capture STDERR from an external command?>
46 my $stderr = IO::Handle->new;
48 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
49 $^X, @switches, '-e', "require q[$lib]"))
50 if $ENV{PERL_COMPILE_TEST_DEBUG};
52 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
53 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
54 my @_warnings = <$stderr>;
56 is($?, 0, "$lib loaded ok");
58 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
59 and not eval { +require blib; blib->VERSION('1.01') };
64 push @warnings, @_warnings;
68 foreach my $file (@scripts)
70 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
73 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
74 @switches = (@switches, split(' ', $1)) if $1;
76 close $fh and skip("$file uses -T; not testable with PERL5LIB", 1)
77 if grep { $_ eq '-T' } @switches and $ENV{PERL5LIB};
79 my $stderr = IO::Handle->new;
81 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
82 $^X, @switches, '-c', $file))
83 if $ENV{PERL_COMPILE_TEST_DEBUG};
85 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
86 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
87 my @_warnings = <$stderr>;
89 is($?, 0, "$file compiled ok");
91 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
92 and not eval { +require blib; blib->VERSION('1.01') };
94 # in older perls, -c output is simply the file portion of the path being tested
95 if (@_warnings = grep { !/\bsyntax OK$/ }
96 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
99 push @warnings, @_warnings;
105 is(scalar(@warnings), 0, 'no warnings found')
106 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};