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.029;
2             # ABSTRACT: something used as a delegating agent to 'dzil test'
3              
4 14     14   6932 use Moose::Role;
  14         57  
  14         110  
5             with 'Dist::Zilla::Role::Plugin';
6              
7 14     14   73005 use Dist::Zilla::Pragmas;
  14         45  
  14         278  
8              
9 14     14   118 use namespace::autoclean;
  14         42  
  14         112  
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.029
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 released
87             in the last two to three years. (That is, if the most recently released
88             version is v5.40, then this module should work on both v5.40 and v5.38.)
89              
90             Although it may work on older versions of perl, no guarantee is made that the
91             minimum required version will not be increased. The version may be increased
92             for any reason, and there is no promise that patches will be accepted to lower
93             the minimum required perl.
94              
95             =head1 ATTRIBUTES
96              
97             =head2 default_jobs
98              
99             This attribute is the default value that should be used as the C<jobs> argument
100             to the C<test> method.
101              
102             =head1 METHODS
103              
104             =head2 test
105              
106             This method should throw an exception on failure.
107              
108             =head1 AUTHOR
109              
110             Ricardo SIGNES 😏 <cpan@semiotic.systems>
111              
112             =head1 COPYRIGHT AND LICENSE
113              
114             This software is copyright (c) 2022 by Ricardo SIGNES.
115              
116             This is free software; you can redistribute it and/or modify it under
117             the same terms as the Perl 5 programming language system itself.
118              
119             =cut