]> Dogcows Code - chaz/p5-Acme-Test-LogicalEquivalence/blob - t/00-compile.t
Version 0.001
[chaz/p5-Acme-Test-LogicalEquivalence] / t / 00-compile.t
1 use 5.006;
2 use strict;
3 use warnings;
4
5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.056
6
7 use Test::More;
8
9 plan tests => 2 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
10
11 my @module_files = (
12 'Acme/Test/LogicalEquivalence.pm'
13 );
14
15 my @scripts = (
16 'bin/test-logical-equivalence'
17 );
18
19 # no fake home requested
20
21 my @switches = (
22 -d 'blib' ? '-Mblib' : '-Ilib',
23 );
24
25 use File::Spec;
26 use IPC::Open3;
27 use IO::Handle;
28
29 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
30
31 my @warnings;
32 for my $lib (@module_files)
33 {
34 # see L<perlfaq8/How can I capture STDERR from an external command?>
35 my $stderr = IO::Handle->new;
36
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};
40
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>;
44 waitpid($pid, 0);
45 is($?, 0, "$lib loaded ok");
46
47 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
48 and not eval { require blib; blib->VERSION('1.01') };
49
50 if (@_warnings)
51 {
52 warn @_warnings;
53 push @warnings, @_warnings;
54 }
55 }
56
57 foreach my $file (@scripts)
58 { SKIP: {
59 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
60 my $line = <$fh>;
61
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;
64
65 my $stderr = IO::Handle->new;
66
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};
70
71 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
72 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
73 my @_warnings = <$stderr>;
74 waitpid($pid, 0);
75 is($?, 0, "$file compiled ok");
76
77 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
78 and not eval { require blib; blib->VERSION('1.01') };
79
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)
83 {
84 warn @_warnings;
85 push @warnings, @_warnings;
86 }
87 } }
88
89
90
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};
93
94
This page took 0.041015 seconds and 4 git commands to generate.