File Coverage

blib/lib/Dist/Zilla/Plugin/MakeMaker/Runner.pm
Criterion Covered Total %
statement 31 31 100.0
branch 9 18 50.0
condition 3 9 33.3
subroutine 6 6 100.0
pod 0 2 0.0
total 49 66 74.2


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::MakeMaker::Runner 6.029;
2             # ABSTRACT: Test and build dists with a Makefile.PL
3              
4 13     13   168 use Moose;
  13         39  
  13         106  
5             with(
6             'Dist::Zilla::Role::BuildRunner',
7             'Dist::Zilla::Role::TestRunner',
8             );
9              
10 13     13   89572 use Dist::Zilla::Pragmas;
  13         35  
  13         113  
11              
12 13     13   108 use namespace::autoclean;
  13         46  
  13         124  
13              
14 13     13   985 use Config;
  13         59  
  13         6819  
15              
16             has 'make_path' => (
17             isa => 'Str',
18             is => 'ro',
19             default => $Config{make} || 'make',
20             );
21              
22             sub build {
23 2     2 0 6 my $self = shift;
24              
25 2         65 my $make = $self->make_path;
26              
27 2 50       20 my $makefile = $^O eq 'VMS' ? 'Descrip.MMS' : 'Makefile';
28              
29             return
30 2 50 33     50 if -e $makefile and (stat 'Makefile.PL')[9] <= (stat $makefile)[9];
31              
32 2         39 $self->log_debug("running $^X Makefile.PL");
33 2 50       514396 system($^X => qw(Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none)) and die "error with Makefile.PL\n";
34              
35 2         213 $self->log_debug("running $make");
36 2 50       710142 system($make) and die "error running $make\n";
37              
38 2         110 return;
39             }
40              
41             sub test {
42 2     2 0 61 my ($self, $target, $arg) = @_;
43              
44 2         88 my $make = $self->make_path;
45 2         16 $self->build;
46              
47             my $job_count = $arg && exists $arg->{jobs}
48             ? $arg->{jobs}
49 2 50 33     502 : $self->default_jobs;
50              
51 2         55 my $jobs = "j$job_count";
52 2         27 my $ho = "HARNESS_OPTIONS";
53 2 50       104 local $ENV{$ho} = $ENV{$ho} ? "$ENV{$ho}:$jobs" : $jobs;
54              
55 2 50       166 $self->log_debug(join(' ', "running $make test", ( $self->zilla->logger->get_debug ? 'TEST_VERBOSE=1' : () )));
56             system($make, 'test',
57 2 50 33     227 ( $self->zilla->logger->get_debug || $arg->{test_verbose} ? 'TEST_VERBOSE=1' : () ),
    50          
58             ) and die "error running $make test\n";
59              
60 2         1495686 return;
61             }
62              
63             __PACKAGE__->meta->make_immutable;
64             1;
65              
66             __END__
67              
68             =pod
69              
70             =encoding UTF-8
71              
72             =head1 NAME
73              
74             Dist::Zilla::Plugin::MakeMaker::Runner - Test and build dists with a Makefile.PL
75              
76             =head1 VERSION
77              
78             version 6.029
79              
80             =head1 PERL VERSION
81              
82             This module should work on any version of perl still receiving updates from
83             the Perl 5 Porters. This means it should work on any version of perl released
84             in the last two to three years. (That is, if the most recently released
85             version is v5.40, then this module should work on both v5.40 and v5.38.)
86              
87             Although it may work on older versions of perl, no guarantee is made that the
88             minimum required version will not be increased. The version may be increased
89             for any reason, and there is no promise that patches will be accepted to lower
90             the minimum required perl.
91              
92             =head1 AUTHOR
93              
94             Ricardo SIGNES 😏 <cpan@semiotic.systems>
95              
96             =head1 COPYRIGHT AND LICENSE
97              
98             This software is copyright (c) 2022 by Ricardo SIGNES.
99              
100             This is free software; you can redistribute it and/or modify it under
101             the same terms as the Perl 5 programming language system itself.
102              
103             =cut