line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Crontab::Format; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
74346
|
use 5.008001; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
117
|
|
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
126
|
|
5
|
3
|
|
|
3
|
|
24
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
94
|
|
6
|
3
|
|
|
3
|
|
17
|
use base 'Exporter'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
328
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
21
|
use Test::Builder; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
62
|
|
9
|
3
|
|
|
3
|
|
3323
|
use Parse::Crontab 0.03; |
|
3
|
|
|
|
|
350887
|
|
|
3
|
|
|
|
|
1254
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Check crontab format validity |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw( |
16
|
|
|
|
|
|
|
crontab_format_ok |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub import { |
20
|
3
|
|
|
3
|
|
36
|
my $self = shift; |
21
|
3
|
|
|
|
|
8
|
my $pack = caller; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
26
|
my $test = Test::Builder->new; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
44
|
$test->exported_to( $pack ); |
26
|
3
|
|
|
|
|
84
|
$test->plan( @_ ); |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
5041
|
$self->export_to_level( 1, $self, @EXPORT ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub crontab_format_ok { |
32
|
8
|
|
|
8
|
1
|
13233
|
my ($thingy) = @_; |
33
|
|
|
|
|
|
|
|
34
|
8
|
|
|
|
|
31
|
my $test = Test::Builder->new; |
35
|
|
|
|
|
|
|
|
36
|
8
|
100
|
|
|
|
37
|
if( ref $thingy eq 'SCALAR' ){ |
37
|
3
|
100
|
|
|
|
4
|
if( length ${ $thingy } == 0 ){ |
|
3
|
|
|
|
|
9
|
|
38
|
1
|
|
|
|
|
6
|
$test->ok( 0, "scalar content" ); |
39
|
1
|
|
|
|
|
107
|
$test->diag("content is empty"); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else{ |
42
|
2
|
|
|
|
|
5
|
my $crontab = Parse::Crontab->new( content => ${ $thingy }, verbose => 0 ); |
|
2
|
|
|
|
|
35
|
|
43
|
2
|
100
|
|
|
|
4688
|
if( $crontab->is_valid ){ |
44
|
1
|
|
|
|
|
28
|
$test->ok( 1, "crontab format: scalar content" ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else{ |
47
|
1
|
|
|
|
|
13
|
$test->ok( 0, "scalar content" ); |
48
|
|
|
|
|
|
|
# $test->diag( $crontab->error_messages ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else{ |
53
|
5
|
|
|
|
|
7
|
my $file = $thingy; |
54
|
5
|
100
|
66
|
|
|
158
|
if( not -f $file or not -r $file ){ |
|
|
100
|
|
|
|
|
|
55
|
2
|
|
|
|
|
11
|
$test->ok( 0, $file ); |
56
|
2
|
|
|
|
|
192
|
$test->diag( sprintf "file '%s' not readable", $file ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
elsif( -z $file ){ |
59
|
1
|
|
|
|
|
6
|
$test->ok( 0, $file ); |
60
|
1
|
|
|
|
|
90
|
$test->diag( sprintf "file '%s' is empty", $file ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else{ |
63
|
2
|
|
|
|
|
37
|
my $crontab = Parse::Crontab->new( file => $file, verbose => 0 ); |
64
|
2
|
100
|
|
|
|
5367
|
if( $crontab->is_valid ){ |
65
|
1
|
|
|
|
|
38
|
$test->ok( 1, sprintf "crontab format: %s", $file ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else{ |
68
|
1
|
|
|
|
|
14
|
$test->ok( 0, $file ); |
69
|
|
|
|
|
|
|
# $test->diag( $crontab->error_messages ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |