blib/lib/App/DuckPAN/Cmd/Test.pm

filter: Statementstmt 33.9% 18 / 53 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 1 totaltotal 21.7% 22 / 101 CC 19 SCAR 56.7
CC
19
Cov
20%
run
380.0
__ANON__
2.0
__ANON__
2.0
CRAP 289.1
« blib/lib/App/DuckPAN/Cmd/New.pm ↑ Summary blib/lib/App/DuckPAN/Cmd/Server.pm »
1 package App::DuckPAN::Cmd::Test;
2 1 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Command for running the tests of this library
4 1 $App::DuckPAN::Cmd::Test::VERSION = '1021';
5 1 ▶use MooX;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 with qw( App::DuckPAN::Cmd );
7  
8 1 ▶use File::Find::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use MooX::Options protect_argv => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 option full => (
13 is => 'ro',
14 lazy => 1,
15 short => 'f',
16 0 ▶ default => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 1 doc => 'run full test suite via dzil',
18 );
19  
20 option verbose => (
21 is => 'ro',
22 short => 'v',
23 0 ▶ default => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 1 doc => 'verbose test output',
25 );
26  
27 1 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 0 ▶sub run {
Subroutine run: not called CC=19 SCAR=59.4
Pod undocumented
30 0 my ($self, @args) = @_;
31  
32 0 $ENV{'DDG_VERBOSE_TEST'} = $self->verbose;
33  
34 0 my $ia_type = $self->app->get_ia_type->{name};
35  
36 0 my $ret = 0;
37  
38 0 ▶ if ($self->full) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->full) { } 0 0 0
39 0 ▶ $self->app->emit_error('Could not find dist.ini.') unless -e 'dist.ini';
Branch: 1 branch
BranchTrueFalseTotal
unless -e "dist.ini" 0 0 0
40 0 ▶ $self->app->emit_error('Could not begin testing. Is Dist::Zilla installed?') if $ret = system('dzil test');
Branch: 1 branch
BranchTrueFalseTotal
if $ret = system("dzil test") 0 0 0
41 }
42 else {
43 0 ▶ my @to_test = ('t') unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 0 0
44 0 my @cheat_sheet_tests;
45 0 foreach my $ia_name (@args) {
46 0 ▶ if ($ia_name =~ /_cheat_sheet$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ia_name =~ /_cheat_sheet$/) 0 0 0
47 0 ▶ $self->app->emit_and_exit(1, 'Cheat sheets can only be tested in Goodies')
Branch: 1 branch
BranchTrueFalseTotal
unless $ia_type eq "Goodie" 0 0 0
48 unless $ia_type eq 'Goodie';
49 0 $ia_name =~ s/_cheat_sheet$//;
50 0 $ia_name =~ s/_/-/g;
51 0 push @cheat_sheet_tests, $ia_name;
52 0 next;
53 }
54 # Unfortunately we can't just use the name, because some have
55 # spaces - thus we grab the end of the package name.
56 0 my $ia = $self->app->get_ia_by_name($ia_name);
57 0 ▶ $self->app->emit_and_exit(1, "Could not find an Instant Answer with name '$ia_name'") unless $ia;
Branch: 1 branch
BranchTrueFalseTotal
unless $ia 0 0 0
58 0 my $id = $ia->{id};
59  
60 0 ▶ if (my ($perl_module) = $ia->{perl_module} =~ /::(\w+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($perl_module) = $ia->{"perl_module"} =~ /::(\w+)$/) 0 0 0
61 0 ▶ if (-d "t/$perl_module") {
Branch: 2 branches
BranchTrueFalseTotal
if (-d "t/$perl_module") { } 0 0 0
elsif (my(@test_file) = 'File::Find::Rule'->name("$perl_module.t")->in('t')) { } 0 0 0
62 0 push @to_test, "t/$perl_module";
63 }
64 elsif (my @test_file = File::Find::Rule->name("$perl_module.t")->in('t')) {
65 0 push @to_test, "@test_file";
66 }
67 }
68  
69 0 ▶ if ($ia_type eq 'Fathead') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ia_type eq "Fathead") 0 0 0
70 0 my $path = "lib/fathead/$id/output.txt";
71 0 ▶ if (-f $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $path) { } 0 0 0
72 0 $ENV{'DDG_TEST_FATHEAD'} = $id;
73 0 push @to_test, "t/validate_fathead.t";
74 } else {
75 0 $self->app->emit_and_exit(1, "Could not find output.txt for $id in $path");
76 }
77 }
78  
79 0 ▶ $self->app->emit_and_exit(1, "Could not find any tests for $id $ia_type") unless @to_test;
Branch: 1 branch
BranchTrueFalseTotal
unless @to_test 0 0 0
80 };
81  
82 0 ▶ $self->app->emit_error('Tests failed! See output above for details') if @to_test and $ret = system("prove -lr @to_test");
Branch: 1 branch
BranchTrueFalseTotal
if @to_test and $ret = system("prove -lr @to_test") 0 0 0
Condition0%0/3
@to_test and $ret = system("prove -lr @to_test")
!ll&&!rl&&r
000
MC/DC0%0/2
@to_test and $ret = system("prove -lr @to_test")
@to_test $ret = system("prove -lr @to_test")
Truth table0%0/3
A and B
A= @to_testB= $ret = system("prove -lr @to_test")
ABresult
0X0
100
111
83 0 ▶ $self->app->emit_error('Tests failed! See output above for details') if @cheat_sheet_tests and $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests");
Branch: 1 branch
BranchTrueFalseTotal
if @cheat_sheet_tests and $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests") 0 0 0
Condition0%0/3
@cheat_sheet_tests and $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests")
!ll&&!rl&&r
000
MC/DC0%0/2
@cheat_sheet_tests and $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests")
@cheat_sheet_tests $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests")
Truth table0%0/3
A and B
A= @cheat_sheet_testsB= $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests")
ABresult
0X0
100
111
84 }
85  
86 0 return $ret;
87 }
88  
89 1 1;
90  
91 __END__
« blib/lib/App/DuckPAN/Cmd/New.pm ↑ Summary blib/lib/App/DuckPAN/Cmd/Server.pm »