line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# PODNAME: App::Prove::Elasticsearch::Harness |
2
|
|
|
|
|
|
|
# ABSTRACT: Harness for uploading test results to elasticsearch |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::Prove::Elasticsearch::Harness; |
5
|
|
|
|
|
|
|
$App::Prove::Elasticsearch::Harness::VERSION = '0.001'; |
6
|
1
|
|
|
1
|
|
103064
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use parent qw/TAP::Harness/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# inject parser_class as Test::Rail::Parser. |
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
1
|
245
|
my $class = shift; |
14
|
1
|
|
|
|
|
2
|
my $arg_for = shift; |
15
|
1
|
|
|
|
|
3
|
$arg_for->{parser_class} = 'App::Prove::Elasticsearch::Parser'; |
16
|
1
|
|
|
|
|
12
|
my $self = $class->SUPER::new($arg_for); |
17
|
1
|
|
|
|
|
7001
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub make_parser { |
21
|
1
|
|
|
1
|
1
|
3542
|
my ($self, $job) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
10
|
my $args = $self->SUPER::_get_parser_args($job); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
89
|
my @relevant_keys = |
26
|
|
|
|
|
|
|
qw{SERVER_HOST SERVER_PORT CLIENT_INDEXER CLIENT_BLAMER CLIENT_VERSIONER CLIENT_PLATFORMER CLIENT_AUTODISCOVER}; |
27
|
|
|
|
|
|
|
my @keys_filtered = grep { |
28
|
1
|
|
|
|
|
10
|
my $subj = $_; |
|
34
|
|
|
|
|
35
|
|
29
|
34
|
|
|
|
|
35
|
grep { $_ eq $subj } @relevant_keys |
|
238
|
|
|
|
|
276
|
|
30
|
|
|
|
|
|
|
} keys(%ENV); |
31
|
1
|
|
|
|
|
4
|
foreach my $key (@keys_filtered) { |
32
|
0
|
|
|
|
|
0
|
my $km = lc($key); |
33
|
0
|
|
|
|
|
0
|
$km =~ s/_/./g; |
34
|
0
|
|
|
|
|
0
|
$args->{$km} = $ENV{$key}; |
35
|
0
|
|
|
|
|
0
|
$self->{$km} = $ENV{$key}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
4
|
$self->SUPER::_make_callback('parser_args', $args, $job->as_array_ref); |
39
|
1
|
|
|
|
|
27
|
my $parser = $self->SUPER::_construct($self->SUPER::parser_class, $args); |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
27
|
$self->SUPER::_make_callback('made_parser', $parser, $job->as_array_ref); |
42
|
1
|
|
|
|
|
14
|
my $session = |
43
|
|
|
|
|
|
|
$self->SUPER::formatter->open_test($job->description, $parser); |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
93
|
return ($parser, $session); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub runtests { |
49
|
2
|
|
|
2
|
1
|
819
|
my ($self, @tests) = @_; |
50
|
|
|
|
|
|
|
|
51
|
2
|
100
|
|
|
|
6
|
if ($ENV{CLIENT_AUTODISCOVER}) { |
52
|
1
|
|
|
|
|
4
|
my $searcher = $self->_require_deps(); |
53
|
1
|
|
|
|
|
5
|
@tests = $self->_filter_tests_with_results($searcher, @tests); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
11
|
return $self->SUPER::runtests(@tests); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _filter_tests_with_results { |
60
|
1
|
|
|
1
|
|
404
|
my ($self, $searcher, @tests) = @_; |
61
|
1
|
|
|
|
|
3
|
my $indexer = $ENV{CLIENT_INDEXER}; |
62
|
|
|
|
|
|
|
my $conf = { |
63
|
|
|
|
|
|
|
'server.host' => $ENV{SERVER_HOST}, |
64
|
|
|
|
|
|
|
'server.port' => $ENV{SERVER_PORT}, |
65
|
|
|
|
|
|
|
'client.versioner' => $ENV{CLIENT_VERSIONER}, |
66
|
|
|
|
|
|
|
'client.platformer' => $ENV{CLIENT_PLATFORMER}, |
67
|
1
|
|
|
|
|
5
|
}; |
68
|
1
|
|
|
|
|
6
|
my $s = $searcher->new($conf, $indexer); |
69
|
1
|
|
|
|
|
7
|
return $s->filter(@tests); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _require_deps { |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
1
|
|
494
|
eval "require $ENV{CLIENT_INDEXER}"; |
75
|
1
|
50
|
|
|
|
5
|
die $@ if $@; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
3
|
my $runner = |
78
|
|
|
|
|
|
|
"App::Prove::Elasticsearch::Searcher::$ENV{CLIENT_AUTODISCOVER}"; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
36
|
eval "require $runner"; |
81
|
1
|
50
|
|
|
|
6
|
die $@ if $@; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
3
|
return $runner; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |