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.058
6
7 use Test::More 0.94;
8
9 plan tests => 26;
10
11 my @module_files = (
12 'Devel/REPL.pm',
13 'Devel/REPL/Error.pm',
14 'Devel/REPL/Meta/Plugin.pm',
15 'Devel/REPL/Plugin.pm',
16 'Devel/REPL/Plugin/B/Concise.pm',
17 'Devel/REPL/Plugin/Colors.pm',
18 'Devel/REPL/Plugin/Commands.pm',
19 'Devel/REPL/Plugin/DumpHistory.pm',
20 'Devel/REPL/Plugin/FancyPrompt.pm',
21 'Devel/REPL/Plugin/FindVariable.pm',
22 'Devel/REPL/Plugin/History.pm',
23 'Devel/REPL/Plugin/OutputCache.pm',
24 'Devel/REPL/Plugin/Packages.pm',
25 'Devel/REPL/Plugin/Peek.pm',
26 'Devel/REPL/Plugin/ReadLineHistory.pm',
27 'Devel/REPL/Plugin/ShowClass.pm',
28 'Devel/REPL/Plugin/Timing.pm',
29 'Devel/REPL/Plugin/Turtles.pm',
30 'Devel/REPL/Profile.pm',
31 'Devel/REPL/Profile/Default.pm',
32 'Devel/REPL/Profile/Minimal.pm',
33 'Devel/REPL/Profile/Standard.pm',
34 'Devel/REPL/Script.pm'
35 );
36
37 my @scripts = (
38 'examples/dbic_project_profile.pl',
39 'script/re.pl'
40 );
41
42 # no fake home requested
43
44 my @switches = (
45 -d 'blib' ? '-Mblib' : '-Ilib',
46 );
47
48 use File::Spec;
49 use IPC::Open3;
50 use IO::Handle;
51
52 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
53
54 my @warnings;
55 for my $lib (@module_files)
56 {
57 # see L<perlfaq8/How can I capture STDERR from an external command?>
58 my $stderr = IO::Handle->new;
59
60 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
61 $^X, @switches, '-e', "require q[$lib]"))
62 if $ENV{PERL_COMPILE_TEST_DEBUG};
63
64 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
65 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
66 my @_warnings = <$stderr>;
67 waitpid($pid, 0);
68 is($?, 0, "$lib loaded ok");
69
70 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
71 and not eval { +require blib; blib->VERSION('1.01') };
72
73 if (@_warnings)
74 {
75 warn @_warnings;
76 push @warnings, @_warnings;
77 }
78 }
79
80 foreach my $file (@scripts)
81 { SKIP: {
82 open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
83 my $line = <$fh>;
84
85 close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
86 @switches = (@switches, split(' ', $1)) if $1;
87
88 close $fh and skip("$file uses -T; not testable with PERL5LIB", 1)
89 if grep { $_ eq '-T' } @switches and $ENV{PERL5LIB};
90
91 my $stderr = IO::Handle->new;
92
93 diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
94 $^X, @switches, '-c', $file))
95 if $ENV{PERL_COMPILE_TEST_DEBUG};
96
97 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
98 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
99 my @_warnings = <$stderr>;
100 waitpid($pid, 0);
101 is($?, 0, "$file compiled ok");
102
103 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
104 and not eval { +require blib; blib->VERSION('1.01') };
105
106 # in older perls, -c output is simply the file portion of the path being tested
107 if (@_warnings = grep { !/\bsyntax OK$/ }
108 grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
109 {
110 warn @_warnings;
111 push @warnings, @_warnings;
112 }
113 } }
114
115
116
117 is(scalar(@warnings), 0, 'no warnings found')
118 or diag 'got warnings: ', explain(\@warnings);
119
120 BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing;