File Coverage

blib/lib/Dist/Zilla/Role/BuildPL.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 14 0.0
condition 0 9 0.0
subroutine 3 5 60.0
pod 0 2 0.0
total 12 56 21.4


line stmt bran cond sub pod time code
1             package Dist::Zilla::Role::BuildPL 6.037;
2             # ABSTRACT: Common ground for Build.PL based builders
3              
4 3     3   2992 use Moose::Role;
  3         7  
  3         33  
5             with 'Dist::Zilla::Role::InstallTool',
6             'Dist::Zilla::Role::BuildRunner',
7             'Dist::Zilla::Role::TestRunner';
8              
9 3     3   15659 use Dist::Zilla::Pragmas;
  3         8  
  3         24  
10              
11 3     3   20 use namespace::autoclean;
  3         309  
  3         31  
12              
13             #pod =head1 DESCRIPTION
14             #pod
15             #pod This role is a helper for Build.PL based installers. It implements the
16             #pod L<Dist::Zilla::Plugin::BuildRunner> and L<Dist::Zilla::Plugin::TestRunner>
17             #pod roles, and requires you to implement the L<Dist::Zilla::Plugin::PrereqSource>
18             #pod and L<Dist::Zilla::Plugin::InstallTool> roles yourself.
19             #pod
20             #pod =cut
21              
22             sub build {
23 0     0 0   my $self = shift;
24              
25             return
26 0 0 0       if -e 'Build' and (stat 'Build.PL')[9] <= (stat 'Build')[9];
27              
28 0           $self->log_debug("running $^X Build.PL");
29 0 0         system $^X, 'Build.PL' and die "error with Build.PL\n";
30              
31 0           $self->log_debug("running $^X Build");
32 0 0         system $^X, 'Build' and die "error running $^X Build\n";
33              
34 0           return;
35             }
36              
37             sub test {
38 0     0 0   my ($self, $target, $arg) = @_;
39              
40 0           $self->build;
41              
42             my $job_count = $arg && exists $arg->{jobs}
43             ? $arg->{jobs}
44 0 0 0       : $self->default_jobs;
45 0           my $jobs = "j$job_count";
46 0           my $ho = "HARNESS_OPTIONS";
47 0 0         local $ENV{$ho} = $ENV{$ho} ? "$ENV{$ho}:$jobs" : $jobs;
48              
49 0 0 0       my @testing = $self->zilla->logger->get_debug || $arg->{test_verbose} ? '--verbose' : ();
50              
51 0           $self->log_debug('running ' . join(' ', $^X, 'Build', 'test', @testing));
52 0 0         system $^X, 'Build', 'test', @testing and die "error running $^X Build test\n";
53              
54 0           return;
55             }
56              
57             1;
58              
59             __END__
60              
61             =pod
62              
63             =encoding UTF-8
64              
65             =head1 NAME
66              
67             Dist::Zilla::Role::BuildPL - Common ground for Build.PL based builders
68              
69             =head1 VERSION
70              
71             version 6.037
72              
73             =head1 DESCRIPTION
74              
75             This role is a helper for Build.PL based installers. It implements the
76             L<Dist::Zilla::Plugin::BuildRunner> and L<Dist::Zilla::Plugin::TestRunner>
77             roles, and requires you to implement the L<Dist::Zilla::Plugin::PrereqSource>
78             and L<Dist::Zilla::Plugin::InstallTool> roles yourself.
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
84             released in the last two to three years. (That is, if the most recently
85             released version is v5.40, then this module should work on both v5.40 and
86             v5.38.)
87              
88             Although it may work on older versions of perl, no guarantee is made that the
89             minimum required version will not be increased. The version may be increased
90             for any reason, and there is no promise that patches will be accepted to
91             lower the minimum required perl.
92              
93             =head1 AUTHOR
94              
95             Ricardo SIGNES 😏 <cpan@semiotic.systems>
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is copyright (c) 2026 by Ricardo SIGNES.
100              
101             This is free software; you can redistribute it and/or modify it under
102             the same terms as the Perl 5 programming language system itself.
103              
104             =cut