line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::App::RunCron; |
2
|
3
|
|
|
3
|
|
80446
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
121
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
75
|
|
4
|
3
|
|
|
3
|
|
16
|
use utf8; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1754
|
use App::RunCron; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
97
|
|
7
|
3
|
|
|
3
|
|
22
|
use Test::More (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
46
|
|
8
|
3
|
|
|
3
|
|
2907
|
use Test::Mock::Guard (); |
|
3
|
|
|
|
|
140882
|
|
|
3
|
|
|
|
|
79
|
|
9
|
3
|
|
|
3
|
|
3214
|
use YAML::Tiny; |
|
3
|
|
|
|
|
20618
|
|
|
3
|
|
|
|
|
225
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
29
|
use parent 'Exporter'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
26
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw/runcron_yml_ok mock_runcron/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub runcron_yml_ok { |
16
|
4
|
|
50
|
4
|
1
|
3602
|
my $yml = shift || 'runcron.yml'; |
17
|
4
|
|
33
|
|
|
20
|
my $description = shift || "test of $yml"; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
8
|
eval { |
20
|
4
|
|
|
|
|
21
|
my $conf = YAML::Tiny::LoadFile($yml); |
21
|
3
|
|
|
|
|
36489
|
my $obj = App::RunCron->new($conf); |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
40
|
my @reporters; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
9
|
for my $reporter_kind (qw/reporter error_reporter common_reporter/) { |
26
|
9
|
100
|
|
|
|
49
|
push @reporters, App::RunCron::_retrieve_reporters($conf->{$reporter_kind}) if $conf->{$reporter_kind}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
8
|
for my $r (@reporters) { |
30
|
5
|
|
|
|
|
31
|
my ($class, $arg) = @$r; |
31
|
5
|
|
66
|
|
|
16
|
App::RunCron::_load_reporter($class)->new($arg || ()); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
}; |
34
|
4
|
|
|
|
|
552
|
my $err = $@; |
35
|
4
|
|
|
|
|
36
|
my $BUILDER = Test::More->builder; |
36
|
4
|
100
|
|
|
|
39
|
if ($err) { |
37
|
2
|
|
|
|
|
13
|
$BUILDER->ok(0, $description); |
38
|
2
|
|
|
|
|
224
|
$BUILDER->diag($err); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
2
|
|
|
|
|
17
|
$BUILDER->ok(1, $description); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub mock_runcron { |
46
|
2
|
50
|
|
2
|
1
|
2424
|
my %args = @_ == 1 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
5
|
my %mock; |
49
|
2
|
|
|
|
|
7
|
for my $key (keys %args) { |
50
|
2
|
|
|
2
|
|
10
|
$mock{$key} = sub { $args{$key} }; |
|
2
|
|
|
|
|
310
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
my $guard = Test::Mock::Guard->new('App::RunCron' => { |
53
|
1
|
|
|
1
|
|
395
|
run => sub { die "can't run mock object" }, |
54
|
0
|
|
|
0
|
|
0
|
command => sub { [qw/dummy/] }, |
55
|
1
|
|
|
1
|
|
281
|
report => sub { 'mock report' }, |
56
|
1
|
|
|
1
|
|
11
|
exit_code => sub { 0 }, |
57
|
2
|
|
|
|
|
37
|
%mock, |
58
|
|
|
|
|
|
|
}); |
59
|
2
|
|
|
|
|
444
|
my $mock = App::RunCron->new; |
60
|
2
|
|
|
|
|
24
|
$mock->{_guard} = $guard; |
61
|
2
|
|
|
|
|
9
|
$mock; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |