line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TheEye; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20602
|
use 5.010; |
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
688
|
use Mouse; |
|
1
|
|
|
|
|
30117
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
1315
|
use POSIX qw/strftime/; |
|
1
|
|
|
|
|
7405
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
2450
|
use File::Util; |
|
1
|
|
|
|
|
23592
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
1182
|
use File::ShareDir 'dist_dir'; |
|
1
|
|
|
|
|
7988
|
|
|
1
|
|
|
|
|
97
|
|
8
|
1
|
|
|
1
|
|
1241
|
use TAP::Parser qw/all/; |
|
1
|
|
|
|
|
224868
|
|
|
1
|
|
|
|
|
58
|
|
9
|
1
|
|
|
1
|
|
1175
|
use TAP::Parser::Aggregator qw/all/; |
|
1
|
|
|
|
|
8122
|
|
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
|
9
|
use Time::HiRes qw(gettimeofday tv_interval); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
1107
|
use Sys::Hostname; |
|
1
|
|
|
|
|
1178
|
|
|
1
|
|
|
|
|
777
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: TheEye is a TAP based monitoring system |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
our $VERSION = '0.5'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'test_dir' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
#default => dist_dir('TheEye') . '/t', |
22
|
|
|
|
|
|
|
default => './t', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'debug' => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
isa => 'Bool', |
28
|
|
|
|
|
|
|
required => 1, |
29
|
|
|
|
|
|
|
default => 0, |
30
|
|
|
|
|
|
|
predicate => 'is_debug', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'hostname' => ( |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
isa => 'Str', |
36
|
|
|
|
|
|
|
default => hostname() |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub run { |
42
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
43
|
0
|
|
|
|
|
|
my $f = File::Util->new(); |
44
|
0
|
0
|
|
|
|
|
print STDERR "processing files in " . $self->test_dir . "\n" |
45
|
|
|
|
|
|
|
if $self->debug; |
46
|
0
|
|
|
|
|
|
my @files = $f->list_dir( $self->test_dir, qw/ --files-only --recurse --pattern=\.t$/ ); |
47
|
0
|
|
|
|
|
|
my @results; |
48
|
0
|
|
|
|
|
|
foreach my $file (@files) { |
49
|
0
|
0
|
|
|
|
|
print STDERR "processing " . $file . "\n" if $self->debug; |
50
|
0
|
|
|
|
|
|
my $t0 = [gettimeofday]; |
51
|
0
|
|
|
|
|
|
my $parser = TAP::Parser->new( { source => $file, merge => 1 } ); |
52
|
0
|
|
|
|
|
|
my $message; |
53
|
|
|
|
|
|
|
my @steps; |
54
|
0
|
|
|
|
|
|
my $t1 = [gettimeofday]; |
55
|
0
|
|
|
|
|
|
while ( my $result = $parser->next ) { |
56
|
0
|
0
|
|
|
|
|
if ( $result->type eq 'comment' ) { |
57
|
0
|
0
|
|
|
|
|
if(exists $steps[-1]){ |
58
|
0
|
|
|
|
|
|
$steps[-1]->{comment} .= $result->as_string . "\n"; |
59
|
|
|
|
|
|
|
} else { |
60
|
|
|
|
|
|
|
# debug output of the tests |
61
|
0
|
|
|
|
|
|
print STDERR $result->as_string."\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
0
|
|
|
|
|
my $hash = { |
66
|
|
|
|
|
|
|
message => $result->as_string, |
67
|
|
|
|
|
|
|
delta => tv_interval($t1), |
68
|
|
|
|
|
|
|
type => $result->type, |
69
|
|
|
|
|
|
|
status => ( $result->is_ok ? 'ok' : 'not_ok' ), |
70
|
|
|
|
|
|
|
}; |
71
|
0
|
|
|
|
|
|
print STDERR Dumper($hash); |
72
|
0
|
|
|
|
|
|
push( @steps, $hash ); |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
$t1 = [gettimeofday]; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
|
my $aggregate = TAP::Parser::Aggregator->new; |
77
|
0
|
|
|
|
|
|
$aggregate->add( 'testcases', $parser ); |
78
|
0
|
|
|
|
|
|
my $hash = { |
79
|
|
|
|
|
|
|
delta => tv_interval($t0), |
80
|
|
|
|
|
|
|
passed => scalar $aggregate->passed, |
81
|
|
|
|
|
|
|
failed => scalar $aggregate->failed, |
82
|
|
|
|
|
|
|
file => $file, |
83
|
|
|
|
|
|
|
'time' => time, |
84
|
|
|
|
|
|
|
steps => \@steps, |
85
|
|
|
|
|
|
|
}; |
86
|
0
|
|
|
|
|
|
push( @results, $hash ); |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
|
return @results; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub save { |
93
|
0
|
|
|
0
|
1
|
|
my ( $self, $tests ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#print STDERR "saving ".($#lines +1)." results\n" if $self->debug; |
96
|
0
|
|
|
|
|
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub graph { |
101
|
0
|
|
|
0
|
1
|
|
my ( $self, $tests ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#print STDERR "saving ".($#lines +1)." results\n" if $self->debug; |
104
|
0
|
|
|
|
|
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub notify { |
109
|
0
|
|
|
0
|
1
|
|
my ( $self, $tests ) = @_; |
110
|
0
|
|
|
|
|
|
foreach my $test ( @{$tests} ) { |
|
0
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
foreach my $step ( @{ $test->{steps} } ) { |
|
0
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ( $step->{status} eq 'not_ok' ) { |
113
|
0
|
|
|
|
|
|
my $message = 'we have a problem: ' . $test->{file} . "\n"; |
114
|
0
|
|
|
|
|
|
$message .= $step->{message} . "\n"; |
115
|
0
|
0
|
|
|
|
|
$message .= $step->{comment} if $step->{comment}; |
116
|
0
|
|
|
|
|
|
print STDERR $message; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#print STDERR "saving ".($#lines +1)." results\n" if $self->debug; |
122
|
0
|
|
|
|
|
|
return; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub load_plugin { |
127
|
0
|
|
|
0
|
1
|
|
my ($self, $plugin) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $plug = 'TheEye::Plugin::'.$plugin; |
130
|
0
|
0
|
|
|
|
|
print STDERR "Loading $plugin Plugin\n" if $self->is_debug; |
131
|
0
|
|
|
|
|
|
with($plug); |
132
|
0
|
|
|
|
|
|
return; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; # End of TheEye |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__END__ |