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.029;
2             # ABSTRACT: Common ground for Build.PL based builders
3              
4 3     3   1967 use Moose::Role;
  3         8  
  3         36  
5             with 'Dist::Zilla::Role::InstallTool',
6             'Dist::Zilla::Role::BuildRunner',
7             'Dist::Zilla::Role::TestRunner';
8              
9 3     3   17321 use Dist::Zilla::Pragmas;
  3         11  
  3         32  
10              
11 3     3   33 use namespace::autoclean;
  3         8  
  3         24  
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.029
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 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