5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
9 plan tests => 11 + ($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'
28 # no fake home requested
31 -d 'blib' ? '-Mblib' : '-Ilib',
38 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
41 for my $lib (@module_files)
43 # see L<perlfaq8/How can I capture STDERR from an external command?>
44 my $stderr = IO::Handle->new;
46 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
47 $^X, @switches, '-e', "require q[$lib]"))
48 if $ENV{PERL_COMPILE_TEST_DEBUG};
50 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
51 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
52 my @_warnings = <$stderr>;
54 is($?, 0, "$lib loaded ok");
56 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
57 and not eval { +require blib; blib->VERSION('1.01') };
62 push @warnings, @_warnings;
66 foreach my $file (@scripts)
68 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
71 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
72 @switches = (@switches, split(' ', $1)) if $1;
74 close $fh and skip("$file uses -T; not testable with PERL5LIB", 1)
75 if grep { $_ eq '-T' } @switches and $ENV{PERL5LIB};
77 my $stderr = IO::Handle->new;
79 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
80 $^X, @switches, '-c', $file))
81 if $ENV{PERL_COMPILE_TEST_DEBUG};
83 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
84 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
85 my @_warnings = <$stderr>;
87 is($?, 0, "$file compiled ok");
89 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
90 and not eval { +require blib; blib->VERSION('1.01') };
92 # in older perls, -c output is simply the file portion of the path being tested
93 if (@_warnings = grep { !/\bsyntax OK$/ }
94 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
97 push @warnings, @_warnings;
103 is(scalar(@warnings), 0, 'no warnings found')
104 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};