5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.057
9 plan tests => 4 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
13 'App/GroupSecret/Crypt.pm',
14 'App/GroupSecret/File.pm'
21 # no fake home requested
24 -d 'blib' ? '-Mblib' : '-Ilib',
31 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
34 for my $lib (@module_files)
36 # see L<perlfaq8/How can I capture STDERR from an external command?>
37 my $stderr = IO::Handle->new;
39 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
40 $^X, @switches, '-e', "require q[$lib]"))
41 if $ENV{PERL_COMPILE_TEST_DEBUG};
43 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
44 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
45 my @_warnings = <$stderr>;
47 is($?, 0, "$lib loaded ok");
49 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
50 and not eval { +require blib; blib->VERSION('1.01') };
55 push @warnings, @_warnings;
59 foreach my $file (@scripts)
61 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
64 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
65 @switches = (@switches, split(' ', $1)) if $1;
67 my $stderr = IO::Handle->new;
69 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
70 $^X, @switches, '-c', $file))
71 if $ENV{PERL_COMPILE_TEST_DEBUG};
73 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
74 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
75 my @_warnings = <$stderr>;
77 is($?, 0, "$file compiled ok");
79 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
80 and not eval { +require blib; blib->VERSION('1.01') };
82 # in older perls, -c output is simply the file portion of the path being tested
83 if (@_warnings = grep { !/\bsyntax OK$/ }
84 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
87 push @warnings, @_warnings;
93 is(scalar(@warnings), 0, 'no warnings found')
94 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};