blib/lib/Dist/Zilla/App/Tester.pm

filter: Statementstmt 85.0% 57 / 67 Branchbran 50.0% 1 / 2 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 76.1% 16 / 21 Podpod 50.0% 1 / 2 totaltotal 77.0% 77 / 100 CC 4 SCAR 5.5
CC
4
Cov
81%
test_dzil
4.1
tempdir
2.0
zilla
2.0
CRAP 1.7
« blib/lib/Dist/Zilla/MVP/Section.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/DistINI.pm »
1 package Dist::Zilla::App::Tester 6.040;
2 # ABSTRACT: testing library for Dist::Zilla::App
3  
4 4 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent 'App::Cmd::Tester::CaptureExternal';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use App::Cmd::Tester 0.306 (); # result_class, ->app
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Dist::Zilla::App;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use File::Copy::Recursive qw(dircopy);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use File::pushd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Dist::Zilla::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶use Sub::Exporter::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
18 exports => [ test_dzil => Sub::Exporter::Util::curry_method() ],
19 groups => [ default => [ qw(test_dzil) ] ],
20 4 };
21  
22 4 ▶use namespace::autoclean -except => 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 20 ▶sub result_class { 'Dist::Zilla::App::Tester::Result' }
Subroutine result_class: called CC=1 SCAR=0.0
Pod undocumented
25  
26 20 ▶sub test_dzil {
Subroutine test_dzil: called CC=4 SCAR=14.2
Pod documented
27 20 my ($self, $source, $argv, $arg) = @_;
28 20 ▶ $arg ||= {};
Condition50%1/2
$arg ||= {}
l!l
020
MC/DC0%0/1
$arg ||= {}
$arg
Truth table50%1/2
A
A= $arg
Aresult
11
00
29  
30 20 ▶ local @INC = map {; ref($_) ? $_ : File::Spec->rel2abs($_) } @INC;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 161 161
31  
32 20 ▶ my $tmpdir = $arg->{tempdir} || File::Temp::tempdir(CLEANUP => 1);
Condition33%1/3
$arg->{'tempdir'} || File::Temp::tempdir('CLEANUP', 1)
l!l&&r!l&&!r
0200
MC/DC0%0/2
$arg->{'tempdir'} || File::Temp::tempdir('CLEANUP', 1)
$arg->{'tempdir'} File::Temp::tempdir('CLEANUP', 1)
Truth table33%1/3
A || B
A= $arg->{'tempdir'}B= File::Temp::tempdir('CLEANUP', 1)
ABresult
1X1
011
000
33 20 my $root = path($tmpdir)->child('source');
34 20 $root->mkpath;
35  
36 20 dircopy($source, $root);
37  
38 20 my $wd = File::pushd::pushd($root);
39  
40 20 local $ENV{DZIL_TESTING} = 1;
41 20 my $result = $self->test_app('Dist::Zilla::App' => $argv);
42 20 $result->{tempdir} = $tmpdir;
43  
44 20 return $result;
45 }
46  
47 {
48 package Dist::Zilla::App::Tester::Result 6.040;
49  
50 4 ▶ BEGIN { our @ISA = qw(App::Cmd::Tester::Result); }
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 0 ▶ sub tempdir {
Subroutine tempdir: not called CC=1 SCAR=6.9
53 0 my ($self) = @_;
54 0 return $self->{tempdir};
55 }
56  
57 0 ▶ sub zilla {
Subroutine zilla: not called CC=1 SCAR=6.9
58 0 my ($self) = @_;
59 0 return $self->app->zilla;
60 }
61  
62 0 ▶ sub build_dir {
Subroutine build_dir: not called CC=1 SCAR=6.9
63 0 my ($self) = @_;
64 0 return $self->zilla->built_in;
65 }
66  
67 0 ▶ sub clear_log_events {
Subroutine clear_log_events: not called CC=1 SCAR=6.9
68 0 my ($self) = @_;
69 0 $self->app->zilla->logger->logger->clear_events;
70 }
71  
72 0 ▶ sub log_events {
Subroutine log_events: not called CC=1 SCAR=6.9
73 0 my ($self) = @_;
74 0 $self->app->zilla->logger->logger->events;
75 }
76  
77 1 ▶ sub log_messages {
Subroutine log_messages: called CC=1 SCAR=0.0
78 1 my ($self) = @_;
79 1 [ map {; $_->{message} } @{ $self->app->zilla->logger->logger->events } ];
80 }
81 }
82  
83 #pod =head1 DESCRIPTION
84 #pod
85 #pod This module exports only one function, C<test_dzil>.
86 #pod
87 #pod =head2 C<test_dzil>
88 #pod
89 #pod This function is used to test L<Dist::Zilla::App>.
90 #pod It receives two mandatory options. The first is the path to a Dist::Zilla-based
91 #pod distribution. The second, an array reference to a list of arguments.
92 #pod
93 #pod The third optional argument is a hash reference, with further options. At the moment
94 #pod the only supported option is c<tempdir>.
95 #pod
96 #pod It returns a L<Dist::Zilla::App::Tester::Result>, that inherits from
97 #pod L<App::Cmd::Tester::Result>. Typical methods called from this result are:
98 #pod
99 #pod =over 4
100 #pod
101 #pod =item C<output>
102 #pod
103 #pod The output of running dzil;
104 #pod
105 #pod =item C<tempdir>
106 #pod
107 #pod The folder used for temporary files.
108 #pod
109 #pod =item C<build_dir>
110 #pod
111 #pod The folder where the distribution was built.
112 #pod
113 #pod =back
114 #pod
115 #pod =cut
116  
117 4 1;
118  
119 __END__
« blib/lib/Dist/Zilla/MVP/Section.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/DistINI.pm »