blib/lib/Dist/Zilla/Plugin/RunExtraTests.pm

filter: Statementstmt 89.3% 42 / 47 Branchbran 54.5% 12 / 22 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 76.7% 66 / 86 CC 15 SCAR 27.9
CC
15
Cov
77%
test
21.3
BEGIN
1.0
BEGIN
1.0
CRAP 16.2
« blib/lib/Dist/Zilla/App/Command/xtest.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/CheckExtraTests.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Dist::Zilla::Plugin::RunExtraTests;
5 # ABSTRACT: support running xt tests via dzil test
6  
7 1 our $VERSION = '0.029';
8  
9 # Dependencies
10 1 ▶use Dist::Zilla 4.3 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Moose 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use namespace::autoclean 0.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # extends, roles, attributes, etc.
15  
16 1 with 'Dist::Zilla::Role::TestRunner';
17  
18 # methods
19  
20 5 ▶sub test {
Subroutine test: called CC=15 SCAR=30.6
Pod undocumented
21 5 my ($self, $target, $arg) = @_;
22  
23 5 my %dirs; @dirs{ grep { -d } glob('xt/*') } = ();
24 5 ▶ delete $dirs{'xt/author'} unless $ENV{AUTHOR_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"AUTHOR_TESTING"} 2 3 5
25 5 ▶ delete $dirs{'xt/smoke'} unless $ENV{AUTOMATED_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"AUTOMATED_TESTING"} 5 0 5
26 5 ▶ delete $dirs{'xt/release'} unless $ENV{RELEASE_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"RELEASE_TESTING"} 5 0 5
27  
28 5 my @dirs = sort keys %dirs;
29 5 my @files = grep { -f } glob('xt/*');
30 5 ▶ return unless @dirs or @files;
Branch: 1 branch
BranchTrueFalseTotal
unless @dirs or @files 2 3 5
Condition100%3/3
@dirs or @files
l!l&&r!l&&!r
122
MC/DC100%2/2
@dirs or @files
@dirs @files
Truth table100%3/3
A or B
A= @dirsB= @files
ABresult
1X1
011
000
31  
32 # If the dist hasn't been built yet, then build it:
33 3 ▶ unless ( -d 'blib' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d "blib") 0 3 3
34 0 my @builders = @{ $self->zilla->plugins_with( -BuildRunner ) };
35 0 ▶ die "no BuildRunner plugins specified" unless @builders;
Branch: 1 branch
BranchTrueFalseTotal
unless @builders 0 0 0
36 0 $_->build for @builders;
37 0 ▶ die "no blib; failed to build properly?" unless -d 'blib';
Branch: 1 branch
BranchTrueFalseTotal
unless -d "blib" 0 0 0
38 }
39  
40 my $jobs = $arg && exists $arg->{jobs}
41 ? $arg->{jobs}
42 3 ▶ : $self->can('default_jobs')
Branch: 2 branches
BranchTrueFalseTotal
$arg && exists $arg->{'jobs'} ? : 0 3 3
$self->can('default_jobs') ? : 3 0 3
Condition33%1/3
$arg and exists $arg->{"jobs"}
!ll&&!rl&&r
300
MC/DC0%0/2
$arg and exists $arg->{"jobs"}
$arg exists $arg->{"jobs"}
Truth table33%1/3
A and B
A= $argB= exists $arg->{"jobs"}
ABresult
0X0
100
111
43 ? $self->default_jobs
44 : 1;
45 3 ▶ my @v = $self->zilla->logger->get_debug ? ('-v') : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->zilla->logger->get_debug ? : 3 0 3
46  
47 3 require App::Prove;
48 3 App::Prove->VERSION('3.00');
49  
50 3 my $app = App::Prove->new;
51  
52 3 $self->log_debug([ 'running prove with args: %s', join(' ', '-j', $jobs, @v, qw/-b xt/) ]);
53 3 $app->process_args( '-j', $jobs, @v, qw/-b xt/);
54  
55 3 $self->log_debug([ 'running prove with args: %s', join(' ', '-j', $jobs, @v, qw/-r -b/, @dirs) ]);
56 3 $app->process_args( '-j', $jobs, @v, qw/-r -b/, @dirs );
57 3 ▶ $app->run or $self->log_fatal("Fatal errors in xt tests");
Branch: 1 branch
BranchTrueFalseTotal
$app->run or $self->log_fatal("Fatal errors in xt tests") 1 2 3
58 1 return;
59 }
60  
61 1 __PACKAGE__->meta->make_immutable;
62  
63 1 1;
64  
65 __END__
« blib/lib/Dist/Zilla/App/Command/xtest.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/CheckExtraTests.pm »