line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::DuckPAN::Cmd::Test; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DDG'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Command for running the tests of this library |
4
|
|
|
|
|
|
|
$App::DuckPAN::Cmd::Test::VERSION = '1019'; |
5
|
1
|
|
|
1
|
|
1206
|
use MooX; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
with qw( App::DuckPAN::Cmd ); |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
641
|
use File::Find::Rule; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
57
|
use MooX::Options protect_argv => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
option full => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
lazy => 1, |
15
|
|
|
|
|
|
|
short => 'f', |
16
|
|
|
|
|
|
|
default => sub { 0 }, |
17
|
|
|
|
|
|
|
doc => 'run full test suite via dzil', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
option verbose => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
short => 'v', |
23
|
|
|
|
|
|
|
default => sub { 0 }, |
24
|
|
|
|
|
|
|
doc => 'verbose test output', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
1563
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
488
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub run { |
30
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
if ($self->full) { |
39
|
0
|
0
|
|
|
|
|
$self->app->emit_error('Could not find dist.ini.') unless -e 'dist.ini'; |
40
|
0
|
0
|
|
|
|
|
$self->app->emit_error('Could not begin testing. Is Dist::Zilla installed?') if $ret = system('dzil test'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
0
|
0
|
|
|
|
|
my @to_test = ('t') unless @args; |
44
|
0
|
|
|
|
|
|
my @cheat_sheet_tests; |
45
|
0
|
|
|
|
|
|
foreach my $ia_name (@args) { |
46
|
0
|
0
|
|
|
|
|
if ($ia_name =~ /_cheat_sheet$/) { |
47
|
0
|
0
|
|
|
|
|
$self->app->emit_and_exit(1, 'Cheat sheets can only be tested in Goodies') |
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
|
0
|
|
|
|
|
$self->app->emit_and_exit(1, "Could not find an Instant Answer with name '$ia_name'") unless $ia; |
58
|
0
|
|
|
|
|
|
my $id = $ia->{id}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if (my ($perl_module) = $ia->{perl_module} =~ /::(\w+)$/) { |
61
|
0
|
0
|
|
|
|
|
if (-d "t/$perl_module") { |
|
|
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
|
0
|
|
|
|
|
if ($ia_type eq 'Fathead') { |
70
|
0
|
|
|
|
|
|
my $path = "lib/fathead/$id/output.txt"; |
71
|
0
|
0
|
|
|
|
|
if (-f $path) { |
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
|
0
|
|
|
|
|
$self->app->emit_and_exit(1, "Could not find any tests for $id $ia_type") unless @to_test; |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
0
|
|
|
|
$self->app->emit_error('Tests failed! See output above for details') if @to_test and $ret = system("prove -lr @to_test"); |
83
|
0
|
0
|
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"); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $ret; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
App::DuckPAN::Cmd::Test - Command for running the tests of this library |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 VERSION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
version 1019 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
DuckDuckGo <open@duckduckgo.com>, Zach Thompson <zach@duckduckgo.com>, Zaahir Moolla <moollaza@duckduckgo.com>, Torsten Raudssus <torsten@raudss.us> L<https://raudss.us/> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by DuckDuckGo, Inc. L<https://duckduckgo.com/>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software, licensed under: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |