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