Debian Codegraph @

xt/author/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.052
6
7 use Test::More;
8
9 plan tests => 2;
10
11 my @module_files = (
12 'IO/Prompt/Tiny.pm'
13 );
14
15
16
17 # fake home for cpan-testers
18 use File::Temp;
19 local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 );
20
21
22 my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib';
23
24 use File::Spec;
25 use IPC::Open3;
26 use IO::Handle;
27
28 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
29
30 my @warnings;
31 for my $lib (@module_files)
32 {
33 # see L<perlfaq8/How can I capture STDERR from an external command?>
34 my $stderr = IO::Handle->new;
35
36 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]");
37 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
38 my @_warnings = <$stderr>;
39 waitpid($pid, 0);
40 is($?, 0, "$lib loaded ok");
41
42 if (@_warnings)
43 {
44 warn @_warnings;
45 push @warnings, @_warnings;
46 }
47 }
48
49
50
51 is(scalar(@warnings), 0, 'no warnings found')
52 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) );
53
54