| 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
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | $self->app->emit_error('Could not find dist.ini.') unless -e 'dist.ini'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $self->app->emit_error('Could not begin testing. Is Dist::Zilla installed?') if $ret = system('dzil test'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my @to_test = ('t') unless @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | my @cheat_sheet_tests; | |||||||||||||||||||||||||||
| 45 | 0 | foreach my $ia_name (@args) { | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($ia_name =~ /_cheat_sheet$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | $self->app->emit_and_exit(1, 'Cheat sheets can only be tested in Goodies') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 58 | 0 | my $id = $ia->{id}; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if (my ($perl_module) = $ia->{perl_module} =~ /::(\w+)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (-d "t/$perl_module") { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 70 | 0 | my $path = "lib/fathead/$id/output.txt"; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if (-f $path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
@to_test and $ret = system("prove -lr @to_test")
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")
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
@cheat_sheet_tests and $ret = system("prove -lr t/CheatSheets/CheatSheetsJSON.t :: @cheat_sheet_tests")
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")
| |||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | return $ret; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | 1; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||