5 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
9 plan tests => 5 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
13 'GraphQL/Client/CLI.pm',
14 'GraphQL/Client/http.pm',
15 'GraphQL/Client/https.pm'
22 # no fake home requested
25 -d 'blib' ? '-Mblib' : '-Ilib',
32 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
35 for my $lib (@module_files)
37 # see L<perlfaq8/How can I capture STDERR from an external command?>
38 my $stderr = IO::Handle->new;
40 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
41 $^X, @switches, '-e', "require q[$lib]"))
42 if $ENV{PERL_COMPILE_TEST_DEBUG};
44 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
45 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
46 my @_warnings = <$stderr>;
48 is($?, 0, "$lib loaded ok");
50 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
51 and not eval { +require blib; blib->VERSION('1.01') };
56 push @warnings, @_warnings;
60 foreach my $file (@scripts)
62 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
65 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
66 @switches = (@switches, split(' ', $1)) if $1;
68 close $fh and skip("$file uses -T; not testable with PERL5LIB", 1)
69 if grep { $_ eq '-T' } @switches and $ENV{PERL5LIB};
71 my $stderr = IO::Handle->new;
73 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
74 $^X, @switches, '-c', $file))
75 if $ENV{PERL_COMPILE_TEST_DEBUG};
77 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
78 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
79 my @_warnings = <$stderr>;
81 is($?, 0, "$file compiled ok");
83 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
84 and not eval { +require blib; blib->VERSION('1.01') };
86 # in older perls, -c output is simply the file portion of the path being tested
87 if (@_warnings = grep { !/\bsyntax OK$/ }
88 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
91 push @warnings, @_warnings;
97 is(scalar(@warnings), 0, 'no warnings found')
98 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};