File Coverage

blib/lib/Dist/Zilla/Role/TestRunner.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::Role::TestRunner 6.037;
2             # ABSTRACT: something used as a delegating agent to 'dzil test'
3              
4 14     14   8776 use Moose::Role;
  14         60  
  14         133  
5             with 'Dist::Zilla::Role::Plugin';
6              
7 14     14   90008 use Dist::Zilla::Pragmas;
  14         35  
  14         159  
8              
9 14     14   117 use namespace::autoclean;
  14         35  
  14         145  
10              
11             #pod =head1 DESCRIPTION
12             #pod
13             #pod Plugins implementing this role have their C<test> method called when
14             #pod testing. It's passed the root directory of the build test dir and an
15             #pod optional hash reference of arguments. Valid arguments include:
16             #pod
17             #pod =for :list
18             #pod * jobs -- if parallel testing is supported, this indicates how many to run at once
19             #pod
20             #pod =method test
21             #pod
22             #pod This method should throw an exception on failure.
23             #pod
24             #pod =cut
25              
26             requires 'test';
27              
28             #pod =attr default_jobs
29             #pod
30             #pod This attribute is the default value that should be used as the C<jobs> argument
31             #pod to the C<test> method.
32             #pod
33             #pod =cut
34              
35             has default_jobs => (
36             is => 'ro',
37             isa => 'Int', # non-negative
38             lazy => 1,
39             default => sub {
40             return ($ENV{HARNESS_OPTIONS} // '') =~ / \b j(\d+) \b /x ? $1 : 1;
41             },
42             );
43              
44             around dump_config => sub {
45             my ($orig, $self) = @_;
46             my $config = $self->$orig;
47              
48             $config->{'' . __PACKAGE__} = { default_jobs => $self->default_jobs };
49              
50             return $config;
51             };
52              
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Dist::Zilla::Role::TestRunner - something used as a delegating agent to 'dzil test'
64              
65             =head1 VERSION
66              
67             version 6.037
68              
69             =head1 DESCRIPTION
70              
71             Plugins implementing this role have their C<test> method called when
72             testing. It's passed the root directory of the build test dir and an
73             optional hash reference of arguments. Valid arguments include:
74              
75             =over 4
76              
77             =item *
78              
79             jobs -- if parallel testing is supported, this indicates how many to run at once
80              
81             =back
82              
83             =head1 PERL VERSION
84              
85             This module should work on any version of perl still receiving updates from
86             the Perl 5 Porters. This means it should work on any version of perl
87             released in the last two to three years. (That is, if the most recently
88             released version is v5.40, then this module should work on both v5.40 and
89             v5.38.)
90              
91             Although it may work on older versions of perl, no guarantee is made that the
92             minimum required version will not be increased. The version may be increased
93             for any reason, and there is no promise that patches will be accepted to
94             lower the minimum required perl.
95              
96             =head1 ATTRIBUTES
97              
98             =head2 default_jobs
99              
100             This attribute is the default value that should be used as the C<jobs> argument
101             to the C<test> method.
102              
103             =head1 METHODS
104              
105             =head2 test
106              
107             This method should throw an exception on failure.
108              
109             =head1 AUTHOR
110              
111             Ricardo SIGNES 😏 <cpan@semiotic.systems>
112              
113             =head1 COPYRIGHT AND LICENSE
114              
115             This software is copyright (c) 2026 by Ricardo SIGNES.
116              
117             This is free software; you can redistribute it and/or modify it under
118             the same terms as the Perl 5 programming language system itself.
119              
120             =cut