Debian Codegraph @

t/00-compile.t

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