Debian Codegraph @

xt/author/00-compile.t

raw
1 use strict;
2 use warnings;
3
4 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.059
5
6 use Test::More 0.94;
7
8 plan tests => 11;
9
10 my @module_files = (
11 'HTTP/Config.pm',
12 'HTTP/Headers.pm',
13 'HTTP/Headers/Auth.pm',
14 'HTTP/Headers/ETag.pm',
15 'HTTP/Headers/Util.pm',
16 'HTTP/Message.pm',
17 'HTTP/Request.pm',
18 'HTTP/Request/Common.pm',
19 'HTTP/Response.pm',
20 'HTTP/Status.pm'
21 );
22
23
24
25 # no fake home requested
26
27 my @switches = (
28 -d 'blib' ? '-Mblib' : '-Ilib',
29 );
30
31 use File::Spec;
32 use IPC::Open3;
33 use IO::Handle;
34
35 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
36
37 my @warnings;
38 for my $lib (@module_files)
39 {
40 # see L<perlfaq8/How can I capture STDERR from an external command?>
41 my $stderr = IO::Handle->new;
42
43 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'}.$str.q{'} }
44 $^X, @switches, '-e', "require q[$lib]"))
45 if $ENV{PERL_COMPILE_TEST_DEBUG};
46
47 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
48 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
49 my @_warnings = <$stderr>;
50 waitpid($pid, 0);
51 is($?, 0, "$lib loaded ok");
52
53 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
54 and not eval { +require blib; blib->VERSION('1.01') };
55
56 if (@_warnings)
57 {
58 warn @_warnings;
59 push @warnings, @_warnings;
60 }
61 }
62
63
64
65 is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', explain(\@warnings);
66
67 BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing;