P5U/Lib/AutoProve.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 89 CC 6 SCAR 19.7
CC
6
Cov
0%
get_app
20.0
change_to_suitable_directory
6.0
build_option_args
6.0
CRAP 7.2
1 package P5U::Lib::AutoProve;
2  
3 BEGIN {
4 $P5U::Lib::AutoProve::AUTHORITY = 'cpan:TOBYINK';
5 $P5U::Lib::AutoProve::VERSION = '0.100';
6 };
7  
8 use 5.010;
9 use strict;
10 use utf8;
11  
12 use App::Prove;
13 use Cwd 'cwd';
14 use Object::AUTHORITY;
15  
16 sub change_to_suitable_directory
17 {
18 my ($self) = @_;
19
20 while (-d '..' and not -d 't')
21 {
22 chdir '..';
23 }
24  
25 unless (-d 't')
26 {
27 die "No suitable test suite found.\n";
28 }
29  
30 return cwd;
31 }
32  
33 sub opts
34 {
35 qw(
36 recurse|r timer verbose|v color|c dry|D failures|f comments|o fork
37 ignore-exit merge|m shuffle|s reverse normalize T t W w jobs|j=i
38 );
39 }
40  
41 sub build_option_args
42 {
43 my ($self, %opt) = @_;
44 my $jobs = delete $opt{jobs};
45
46 my @args =
47 map { "--$_" }
48 sort keys %opt;
49
50 push @args, "--jobs=$jobs" if $jobs;
51
52 return @args;
53 }
54  
55 sub build_lib_args
56 {
57 map { "-I$_" } grep { -d $_ } qw( blib/lib inc lib t/lib xt/lib );
58 }
59  
60 sub get_app
61 {
62 my ($self, %opt) = @_;
63  
64 my $do_author_tests = delete $opt{xt};
65  
66 my $origwd = cwd;
67 my $cwd = $self->change_to_suitable_directory;
68 print "Found suitable test suite within directory '$cwd'.\n";
69  
70 my @args = $self->build_option_args(%opt);
71 push @args, $self->build_lib_args;
72
73 push @args, 't' if -d 't';
74 push @args, 'xt' if -d 'xt' && $do_author_tests;
75
76 chdir $origwd;
77  
78 print join(q{ }, prove => @args), "\n"
79 if $opt{verbose};
80
81 my $app = App::Prove->new;
82 $app->process_args(@args);
83 return ($cwd, $app);
84 }
85  
86 1;
87  
88 __END__