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