| 1 | package TheEye; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Mouse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use POSIX qw/strftime/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use File::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use File::ShareDir 'dist_dir'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use TAP::Parser qw/all/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use TAP::Parser::Aggregator qw/all/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Time::HiRes qw(gettimeofday tv_interval); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Sys::Hostname; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | # ABSTRACT: TheEye is a TAP based monitoring system | ||||||||||
| 14 | # | ||||||||||
| 15 | 1 | our $VERSION = '0.5'; # VERSION | |||||||||
| 16 | |||||||||||
| 17 | 1 | has 'test_dir' => ( | |||||||||
| 18 | is => 'rw', | ||||||||||
| 19 | isa => 'Str', | ||||||||||
| 20 | required => 1, | ||||||||||
| 21 | #default => dist_dir('TheEye') . '/t', | ||||||||||
| 22 | default => './t', | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 1 | has 'debug' => ( | |||||||||
| 26 | is => 'rw', | ||||||||||
| 27 | isa => 'Bool', | ||||||||||
| 28 | required => 1, | ||||||||||
| 29 | default => 0, | ||||||||||
| 30 | predicate => 'is_debug', | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 1 | has 'hostname' => ( | |||||||||
| 34 | is => 'rw', | ||||||||||
| 35 | isa => 'Str', | ||||||||||
| 36 | default => hostname() | ||||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||
| 42 | 0 | my ($self) = @_; | |||||||||
| 43 | 0 | my $f = File::Util->new(); | |||||||||
| 44 | 0 | ▶ | print STDERR "processing files in " . $self->test_dir . "\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | print STDERR "processing " . $file . "\n" if $self->debug; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | ▶ | if ( $result->type eq 'comment' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | ▶ | if(exists $steps[-1]){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | my $hash = { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | ▶ | sub save { | ||||||||
|
Subroutine
save: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 93 | 0 | my ( $self, $tests ) = @_; | |||||||||
| 94 | |||||||||||
| 95 | #print STDERR "saving ".($#lines +1)." results\n" if $self->debug; | ||||||||||
| 96 | 0 | return; | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | |||||||||||
| 100 | 0 | ▶ | sub graph { | ||||||||
|
Subroutine
graph: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 101 | 0 | my ( $self, $tests ) = @_; | |||||||||
| 102 | |||||||||||
| 103 | #print STDERR "saving ".($#lines +1)." results\n" if $self->debug; | ||||||||||
| 104 | 0 | return; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | |||||||||||
| 108 | 0 | ▶ | sub notify { | ||||||||
|
Subroutine
notify: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 109 | 0 | my ( $self, $tests ) = @_; | |||||||||
| 110 | 0 | foreach my $test ( @{$tests} ) { | |||||||||
| 111 | 0 | foreach my $step ( @{ $test->{steps} } ) { | |||||||||
| 112 | 0 | ▶ | if ( $step->{status} eq 'not_ok' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 0 | my $message = 'we have a problem: ' . $test->{file} . "\n"; | |||||||||
| 114 | 0 | $message .= $step->{message} . "\n"; | |||||||||
| 115 | 0 | ▶ | $message .= $step->{comment} if $step->{comment}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | ▶ | sub load_plugin { | ||||||||
|
Subroutine
load_plugin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 127 | 0 | my ($self, $plugin) = @_; | |||||||||
| 128 | |||||||||||
| 129 | 0 | my $plug = 'TheEye::Plugin::'.$plugin; | |||||||||
| 130 | 0 | ▶ | print STDERR "Loading $plugin Plugin\n" if $self->is_debug; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 131 | 0 | with($plug); | |||||||||
| 132 | 0 | return; | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | |||||||||||
| 136 | 1 | 1; # End of TheEye | |||||||||
| 137 | |||||||||||
| 138 | __END__ | ||||||||||