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.030;
2             # ABSTRACT: Test and build dists with a Makefile.PL
3              
4 13     13   107 use Moose;
  13         33  
  13         108  
5             with(
6             'Dist::Zilla::Role::BuildRunner',
7             'Dist::Zilla::Role::TestRunner',
8             );
9              
10 13     13   88795 use Dist::Zilla::Pragmas;
  13         46  
  13         113  
11              
12 13     13   115 use namespace::autoclean;
  13         44  
  13         113  
13              
14 13     13   1132 use Config;
  13         53  
  13         6940  
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 7 my $self = shift;
24              
25 2         89 my $make = $self->make_path;
26              
27 2 50       29 my $makefile = $^O eq 'VMS' ? 'Descrip.MMS' : 'Makefile';
28              
29             return
30 2 50 33     59 if -e $makefile and (stat 'Makefile.PL')[9] <= (stat $makefile)[9];
31              
32 2         50 $self->log_debug("running $^X Makefile.PL");
33 2 50       511577 system($^X => qw(Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none)) and die "error with Makefile.PL\n";
34              
35 2         242 $self->log_debug("running $make");
36 2 50       733801 system($make) and die "error running $make\n";
37              
38 2         108 return;
39             }
40              
41             sub test {
42 2     2 0 64 my ($self, $target, $arg) = @_;
43              
44 2         85 my $make = $self->make_path;
45 2         29 $self->build;
46              
47             my $job_count = $arg && exists $arg->{jobs}
48             ? $arg->{jobs}
49 2 50 33     467 : $self->default_jobs;
50              
51 2         46 my $jobs = "j$job_count";
52 2         26 my $ho = "HARNESS_OPTIONS";
53 2 50       148 local $ENV{$ho} = $ENV{$ho} ? "$ENV{$ho}:$jobs" : $jobs;
54              
55 2 50       141 $self->log_debug(join(' ', "running $make test", ( $self->zilla->logger->get_debug ? 'TEST_VERBOSE=1' : () )));
56             system($make, 'test',
57 2 50 33     271 ( $self->zilla->logger->get_debug || $arg->{test_verbose} ? 'TEST_VERBOSE=1' : () ),
    50          
58             ) and die "error running $make test\n";
59              
60 2         1554175 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.030
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) 2023 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