| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of Test-Reporter-Transport-Metabase |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2010 by David Golden. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# The Apache License, Version 2.0, January 2004 |
|
9
|
|
|
|
|
|
|
# |
|
10
|
1
|
|
|
1
|
|
25351
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
47
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
87
|
|
|
13
|
|
|
|
|
|
|
package Test::Reporter::Transport::Metabase; |
|
14
|
|
|
|
|
|
|
BEGIN { |
|
15
|
1
|
|
|
1
|
|
27
|
$Test::Reporter::Transport::Metabase::VERSION = '1.999008'; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
# ABSTRACT: Metabase transport for Test::Reporter |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
972
|
use Test::Reporter::Transport 1.57 (); |
|
|
1
|
|
|
|
|
174
|
|
|
|
1
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
|
|
our @ISA = qw/Test::Reporter::Transport/; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Carp (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
23
|
1
|
|
|
1
|
|
1099
|
use Config::Perl::V (); |
|
|
1
|
|
|
|
|
2992
|
|
|
|
1
|
|
|
|
|
35
|
|
|
24
|
1
|
|
|
1
|
|
961
|
use CPAN::Testers::Report 1.999001 (); |
|
|
1
|
|
|
|
|
62275
|
|
|
|
1
|
|
|
|
|
26
|
|
|
25
|
1
|
|
|
1
|
|
9
|
use File::Glob (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
26
|
1
|
|
|
1
|
|
4
|
use JSON 2 (); |
|
|
1
|
|
|
|
|
12
|
|
|
|
1
|
|
|
|
|
26
|
|
|
27
|
1
|
|
|
1
|
|
847
|
use Metabase::User::Profile 0.016 (); |
|
|
1
|
|
|
|
|
3147
|
|
|
|
1
|
|
|
|
|
31
|
|
|
28
|
1
|
|
|
1
|
|
839
|
use Metabase::User::Secret 0.016 (); |
|
|
1
|
|
|
|
|
419
|
|
|
|
1
|
|
|
|
|
29
|
|
|
29
|
1
|
|
|
1
|
|
1023
|
use Metabase::Client::Simple 0.008 (); |
|
|
1
|
|
|
|
|
62533
|
|
|
|
1
|
|
|
|
|
978
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
|
32
|
|
|
|
|
|
|
# argument definitions |
|
33
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my %default_args = ( |
|
36
|
|
|
|
|
|
|
client => 'Metabase::Client::Simple' |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
my @allowed_args = qw/uri id_file client/; |
|
39
|
|
|
|
|
|
|
my @required_args = qw/uri id_file/; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
|
42
|
|
|
|
|
|
|
# new |
|
43
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
|
46
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
47
|
0
|
0
|
|
|
|
|
Carp::confess __PACKAGE__ . " requires transport args in key/value pairs\n" |
|
48
|
|
|
|
|
|
|
if @_ % 2; |
|
49
|
0
|
|
|
|
|
|
my %args = ( %default_args, @_ ); |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for my $k ( @required_args ) { |
|
52
|
0
|
0
|
|
|
|
|
Carp::confess __PACKAGE__ . " requires $k argument\n" |
|
53
|
|
|
|
|
|
|
unless exists $args{$k}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
for my $k ( keys %args ) { |
|
57
|
0
|
|
|
|
|
|
Carp::confess __PACKAGE__ . " unknown argument '$k'\n" |
|
58
|
0
|
0
|
|
|
|
|
unless grep { $k eq $_ } @allowed_args; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return bless \%args => $class; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
|
65
|
|
|
|
|
|
|
# send |
|
66
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub send { |
|
69
|
0
|
|
|
0
|
1
|
|
my ($self, $report) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
unless ( eval { $report->distfile } ) { |
|
|
0
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
Carp::confess __PACKAGE__ . ": requires the 'distfile' parameter to be set\n" |
|
73
|
|
|
|
|
|
|
. "Please update CPAN::Reporter and/or CPANPLUS to a version that provides \n" |
|
74
|
|
|
|
|
|
|
. "this information to Test::Reporter. Report will not be sent.\n"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my ($profile, $secret) = $self->_load_id_file; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Load specified metabase client. |
|
80
|
0
|
|
|
|
|
|
my $class = $self->{client}; |
|
81
|
0
|
0
|
|
|
|
|
eval "require $class" |
|
82
|
|
|
|
|
|
|
or Carp::confess __PACKAGE__ . ": could not load client '$class':\n$@\n"; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $client = $class->new( |
|
85
|
|
|
|
|
|
|
uri => $self->{uri}, |
|
86
|
|
|
|
|
|
|
profile => $profile, |
|
87
|
|
|
|
|
|
|
secret => $secret, |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Get facts about Perl config that Test::Reporter doesn't capture |
|
91
|
|
|
|
|
|
|
# Unfortunately we can't do this from the current perl in case this |
|
92
|
|
|
|
|
|
|
# is a report regenerated from a file and isn't the perl that the report |
|
93
|
|
|
|
|
|
|
# was run on |
|
94
|
0
|
|
|
|
|
|
my $perlv = $report->{_perl_version}->{_myconfig}; |
|
95
|
0
|
|
|
|
|
|
my $config = Config::Perl::V::summary(Config::Perl::V::plv2hash($perlv)); |
|
96
|
0
|
|
0
|
|
|
|
my $perl_version = $report->{_perl_version}{_version} || $config->{version}; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Build CPAN::Testers::Report with its various component facts. |
|
99
|
0
|
|
|
|
|
|
my $metabase_report = CPAN::Testers::Report->open( |
|
100
|
|
|
|
|
|
|
resource => 'cpan:///distfile/' . $report->distfile |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$metabase_report->add( 'CPAN::Testers::Fact::LegacyReport' => { |
|
104
|
|
|
|
|
|
|
grade => $report->grade, |
|
105
|
|
|
|
|
|
|
osname => $config->{osname}, |
|
106
|
|
|
|
|
|
|
osversion => $report->{_perl_version}{_osvers}, |
|
107
|
|
|
|
|
|
|
archname => $report->{_perl_version}{_archname}, |
|
108
|
|
|
|
|
|
|
perl_version => $perl_version, |
|
109
|
|
|
|
|
|
|
textreport => $report->report |
|
110
|
|
|
|
|
|
|
}); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# TestSummary happens to be the same as content metadata |
|
113
|
|
|
|
|
|
|
# of LegacyReport for now |
|
114
|
0
|
|
|
|
|
|
$metabase_report->add( 'CPAN::Testers::Fact::TestSummary' => |
|
115
|
|
|
|
|
|
|
[$metabase_report->facts]->[0]->content_metadata() |
|
116
|
|
|
|
|
|
|
); |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# XXX wish we could fill these in with stuff from CPAN::Testers::ParseReport |
|
119
|
|
|
|
|
|
|
# but it has too many dependencies to require for T::R::Transport::Metabase. |
|
120
|
|
|
|
|
|
|
# Could make it optional if installed? Will do this for the offline NNTP |
|
121
|
|
|
|
|
|
|
# archive conversion, so maybe wait until that is written then move here and |
|
122
|
|
|
|
|
|
|
# use if CPAN::Testers::ParseReport is installed -- dagolden, 2009-03-30 |
|
123
|
|
|
|
|
|
|
# $metabase_report->add( 'CPAN::Testers::Fact::TestOutput' => $stuff ); |
|
124
|
|
|
|
|
|
|
# $metabase_report->add( 'CPAN::Testers::Fact::TesterComment' => $stuff ); |
|
125
|
|
|
|
|
|
|
# $metabase_report->add( 'CPAN::Testers::Fact::PerlConfig' => $stuff ); |
|
126
|
|
|
|
|
|
|
# $metabase_report->add( 'CPAN::Testers::Fact::TestEnvironment' => $stuff ); |
|
127
|
|
|
|
|
|
|
# $metabase_report->add( 'CPAN::Testers::Fact::Prereqs' => $stuff ); |
|
128
|
|
|
|
|
|
|
# $metabase_report->add( 'CPAN::Testers::Fact::InstalledModules' => $stuff ); |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
$metabase_report->close(); |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
return $client->submit_fact($metabase_report); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _load_id_file { |
|
136
|
0
|
|
|
0
|
|
|
my ($self) = shift; |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
open my $fh, "<", File::Glob::bsd_glob( $self->{id_file} ) |
|
139
|
|
|
|
|
|
|
or Carp::confess __PACKAGE__. ": could not read ID file '$self->{id_file}'" |
|
140
|
|
|
|
|
|
|
. "\n$!"; |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
my $data = JSON->new->ascii->decode( do { local $/; <$fh> } ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
my $profile = eval { Metabase::User::Profile->from_struct($data->[0]) } |
|
|
0
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
or Carp::confess __PACKAGE__ . ": could not load Metabase profile\n" |
|
146
|
|
|
|
|
|
|
. "from '$self->{id_file}':\n$@"; |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
0
|
|
|
|
|
my $secret = eval { Metabase::User::Secret->from_struct($data->[1]) } |
|
|
0
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
or Carp::confess __PACKAGE__ . ": could not load Metabase secret\n" |
|
150
|
|
|
|
|
|
|
. "from '$self->{id_file}':\n $@"; |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return ($profile, $secret); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=pod |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 NAME |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Test::Reporter::Transport::Metabase - Metabase transport for Test::Reporter |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 VERSION |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
version 1.999008 |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $report = Test::Reporter->new( |
|
172
|
|
|
|
|
|
|
transport => 'Metabase', |
|
173
|
|
|
|
|
|
|
transport_args => [ |
|
174
|
|
|
|
|
|
|
uri => 'http://metabase.example.com:3000/', |
|
175
|
|
|
|
|
|
|
id_file => '/home/jdoe/.metabase/metabase_id.json', |
|
176
|
|
|
|
|
|
|
], |
|
177
|
|
|
|
|
|
|
); |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# use space-separated in a CPAN::Reporter config.ini |
|
180
|
|
|
|
|
|
|
transport = Metabase uri http://metabase.example.com:3000/ ... |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This module submits a Test::Reporter report to the specified Metabase instance. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This requires a network connection to the Metabase uri provided. If you wish |
|
187
|
|
|
|
|
|
|
to save reports during offline operation, see |
|
188
|
|
|
|
|
|
|
L. (Eventually, you may be able to run a local |
|
189
|
|
|
|
|
|
|
Metabase instance to queue reports for later transmission, but this feature has |
|
190
|
|
|
|
|
|
|
not yet been developed.) |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 USAGE |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
See L and L for general usage |
|
195
|
|
|
|
|
|
|
information. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 Transport arguments |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Unlike most other Transport classes, this class requires transport arguments |
|
200
|
|
|
|
|
|
|
to be provided as key-value pairs: |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
my $report = Test::Reporter->new( |
|
203
|
|
|
|
|
|
|
transport => 'Metabase', |
|
204
|
|
|
|
|
|
|
transport_args => [ |
|
205
|
|
|
|
|
|
|
uri => 'http://metabase.example.com:3000/', |
|
206
|
|
|
|
|
|
|
id_file => '/home/jdoe/.metabase/metabase_id.json', |
|
207
|
|
|
|
|
|
|
], |
|
208
|
|
|
|
|
|
|
); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Arguments include: |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=over |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item C (required) |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
The C argument gives the network location of a Metabase instance to receive |
|
217
|
|
|
|
|
|
|
reports. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item C (required) |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
The C argument must be a path to a Metabase ID file. If |
|
222
|
|
|
|
|
|
|
you do not already have an ID file, use the L program to |
|
223
|
|
|
|
|
|
|
create one. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
$ metabase-profile |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
This creates the file F in the current directory. You |
|
228
|
|
|
|
|
|
|
can also give an C<--output> argument to save the file to a different |
|
229
|
|
|
|
|
|
|
location or with a different name. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item C (optional) |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
The C argument is optional and specifies the type of Metabase::Client |
|
234
|
|
|
|
|
|
|
to use to transmit reports to the target Metabase. It defaults to |
|
235
|
|
|
|
|
|
|
L. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 METHODS |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
These methods are only for internal use by Test::Reporter. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 new |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
my $sender = Test::Reporter::Transport::File->new( $params ); |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
The C method is the object constructor. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 send |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$sender->send( $report ); |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
The C method transmits the report. |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 AUTHORS |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=over 4 |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item * |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
David Golden |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Richard Dawe |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
This software is Copyright (c) 2010 by David Golden. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
This is free software, licensed under: |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=cut |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
__END__ |