P5U/Command/Reprove.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 80 CC 4 SCAR 19.2
CC
4
Cov
0%
execute
20.0
BEGIN
2.0
command_names
2.0
CRAP 6.8
1 package P5U::Command::Reprove;
2  
3 use 5.010;
4 use strict;
5 use utf8;
6 use P5U-command;
7  
8 use PerlX::Maybe 0 'maybe';
9  
10 BEGIN {
11 $P5U::Command::Reprove::AUTHORITY = 'cpan:TOBYINK';
12 $P5U::Command::Reprove::VERSION = '0.100';
13 };
14  
15 use constant {
16 abstract => q[download a distribution test suite and run it],
17 usage_desc => q[%c reprove %o],
18 };
19  
20 sub command_names
21 {
22 qw(
23 reprove
24 rp
25 );
26 }
27  
28 sub description
29 {
30 <<'DESCRIPTION'
31 This command downloads a distribution's test suite from CPAN, and runs it
32 locally.
33  
34 This command can be called using two different conventions; named arguments:
35  
36 p5u reprove --release=JSON --version=2.53
37  
38 Or positional arguments:
39  
40 p5u reprove JSON 2.53
41  
42 The first argument is the distribution name or module name; the second
43 argument is the version; and the third argument is the CPAN ID of the
44 author. The presence of "::" is used to disambiguate between distribution
45 and module names; in the case of something like "JSON" which is ambiguous,
46 use a trailing "::" to force it to be interpreted as a module name.
47  
48 When given a distribution name, the version is required. When given a
49 module name, the version can usually be automatically detected. The author
50 can usually be automatically detected.
51 DESCRIPTION
52 }
53  
54 sub opt_spec
55 {
56 return (
57 ["author|a=s", "author of distribution to test"],
58 ["version=s", "version to test"],
59 ["module|m=s", "identify distribution via a module it provides"],
60 ["release|r=s", "name of distribution to test"],
61 ["verbose|v", "verbose output"],
62 )
63 }
64  
65 sub execute
66 {
67 require P5U::Lib::Reprove;
68
69 my ($self, $opt, $args) = @_;
70  
71 foreach my $a (qw< release version author >)
72 {
73 my $val = shift @$args;
74 defined $val or last;
75 $self->usage_error("Do not provide $a as a named and ordinal argument.")
76 if defined $opt->{$a};
77
78 if ($a eq 'release' and $val =~ /::/)
79 {
80 $val =~ s{::$}{};
81 $opt->{module} = $val;
82 next;
83 }
84
85 $opt->{$a} = $val;
86 }
87
88 $self->usage_error("You must provide a distribution or module name.")
89 unless $opt->{release} || $opt->{module};
90
91 P5U::Lib::Reprove::
92 -> new(
93 maybe author => $opt->{author},
94 maybe module => $opt->{module},
95 maybe release => $opt->{release},
96 maybe version => $opt->{version},
97 maybe verbose => $opt->{verbose},
98 working_dir => $self->get_tempdir, ##WS
99 )
100 -> run;
101 }
102  
103 1;