5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.056
9 plan tests => 2 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
12 'Acme/Test/LogicalEquivalence.pm'
16 'bin/test-logical-equivalence'
19 # no fake home requested
22 -d 'blib' ? '-Mblib' : '-Ilib',
29 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
32 for my $lib (@module_files)
34 # see L<perlfaq8/How can I capture STDERR from an external command?>
35 my $stderr = IO::Handle->new;
37 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
38 $^X, @switches, '-e', "require q[$lib]"))
39 if $ENV{PERL_COMPILE_TEST_DEBUG};
41 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
42 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
43 my @_warnings = <$stderr>;
45 is($?, 0, "$lib loaded ok");
47 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
48 and not eval { require blib; blib->VERSION('1.01') };
53 push @warnings, @_warnings;
57 foreach my $file (@scripts)
59 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
62 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
63 @switches = (@switches, split(' ', $1)) if $1;
65 my $stderr = IO::Handle->new;
67 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
68 $^X, @switches, '-c', $file))
69 if $ENV{PERL_COMPILE_TEST_DEBUG};
71 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
72 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
73 my @_warnings = <$stderr>;
75 is($?, 0, "$file compiled ok");
77 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
78 and not eval { require blib; blib->VERSION('1.01') };
80 # in older perls, -c output is simply the file portion of the path being tested
81 if (@_warnings = grep { !/\bsyntax OK$/ }
82 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
85 push @warnings, @_warnings;
91 is(scalar(@warnings), 0, 'no warnings found')
92 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};