| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Parse::Crontab::Simple; |
|
2
|
4
|
|
|
4
|
|
335105
|
use 5.008001; |
|
|
4
|
|
|
|
|
13
|
|
|
3
|
4
|
|
|
4
|
|
16
|
use strict; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
73
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
196
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
448
|
use parent qw/Exporter/; |
|
|
4
|
|
|
|
|
250
|
|
|
|
4
|
|
|
|
|
21
|
|
|
9
|
4
|
|
|
4
|
|
2232
|
use Data::Util; |
|
|
4
|
|
|
|
|
2498
|
|
|
|
4
|
|
|
|
|
183
|
|
|
10
|
4
|
|
|
4
|
|
21
|
use Test::Builder; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
1962
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/match_ok strict_match_ok/; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $PREFIX = '###sample'; |
|
15
|
|
|
|
|
|
|
my $STRICT_MATCH = 0; |
|
16
|
|
|
|
|
|
|
my $TEST = Test::Builder->new; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
|
19
|
4
|
|
|
4
|
|
27
|
my $self = shift; |
|
20
|
4
|
|
|
|
|
6
|
my $pack = caller; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
15
|
$TEST->exported_to( $pack ); |
|
24
|
4
|
|
|
|
|
56
|
$TEST->plan( @_ ); |
|
25
|
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
4740
|
$self->export_to_level( 1, $self, @EXPORT ); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub set_prefix{ |
|
30
|
1
|
|
|
1
|
0
|
2792
|
my ($prefix) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
50
|
|
|
|
6
|
return unless Data::Util::is_string($prefix); |
|
33
|
1
|
|
|
|
|
3
|
$PREFIX = $prefix; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _set_strict_mode{ |
|
37
|
1
|
|
|
1
|
|
3
|
$STRICT_MATCH = 1; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub strict_match_ok{ |
|
41
|
1
|
|
|
1
|
1
|
3137
|
my $crontab = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
4
|
_set_strict_mode(); |
|
44
|
1
|
|
|
|
|
3
|
match_ok( $crontab ); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub match_ok{ |
|
48
|
3
|
|
|
3
|
1
|
3327
|
my $crontab = shift; |
|
49
|
|
|
|
|
|
|
|
|
50
|
3
|
50
|
|
|
|
55
|
return unless Data::Util::is_instance($crontab , 'Parse::Crontab'); |
|
51
|
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
11
|
for my $job ( $crontab->jobs ){ |
|
53
|
8
|
|
|
|
|
2220
|
my $sample = _search_sample( $crontab , $job ); |
|
54
|
8
|
100
|
|
|
|
23
|
if( Data::Util::is_hash_ref($sample) ){ |
|
55
|
7
|
|
|
|
|
16
|
my $ret = $job->schedule->match( %{$sample} ); |
|
|
7
|
|
|
|
|
35
|
|
|
56
|
7
|
|
|
|
|
550
|
$TEST->ok( $ret , sprintf('[%s] matches ok', $job->command)); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
else{ |
|
59
|
1
|
50
|
|
|
|
3
|
if( $STRICT_MATCH ){ |
|
60
|
0
|
|
|
|
|
0
|
$TEST->ok( 0 , sprintf('[%s] does not have sample',$job->command)); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
else{ |
|
63
|
1
|
|
|
|
|
3
|
next; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _search_sample{ |
|
70
|
8
|
|
|
8
|
|
14
|
my ( $crontab , $job ) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
7
|
my $sample_comment; |
|
73
|
8
|
|
|
|
|
9
|
my $find_flg = 0; |
|
74
|
8
|
|
|
|
|
24
|
for my $entry ( $crontab->entries ){ |
|
75
|
36
|
100
|
|
|
|
132
|
if( $find_flg ){ |
|
|
|
100
|
|
|
|
|
|
|
76
|
7
|
50
|
|
|
|
14
|
if( _is_sample( $entry ) ){ |
|
77
|
7
|
|
|
|
|
17
|
return _parse_sample_comment( $entry ); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
else{ |
|
80
|
0
|
|
|
|
|
0
|
next; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
elsif( $entry->line_number eq $job->line_number ){ |
|
84
|
8
|
|
|
|
|
12
|
$find_flg = 1; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
1
|
|
|
|
|
2
|
return; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _is_sample{ |
|
91
|
7
|
|
|
7
|
|
10
|
my $entry = shift; |
|
92
|
7
|
50
|
|
|
|
92
|
return 1 if $entry->line =~ m/\A$PREFIX/; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _parse_sample_comment{ |
|
96
|
7
|
|
|
7
|
|
8
|
my $sample_entry = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
7
|
50
|
|
|
|
92
|
if( $sample_entry->line =~ m/\A$PREFIX (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/){ |
|
99
|
|
|
|
|
|
|
return { |
|
100
|
7
|
|
|
|
|
56
|
year => $1, |
|
101
|
|
|
|
|
|
|
month => $2, |
|
102
|
|
|
|
|
|
|
day => $3, |
|
103
|
|
|
|
|
|
|
hour => $4, |
|
104
|
|
|
|
|
|
|
minute => $5, |
|
105
|
|
|
|
|
|
|
}; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |