| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Chimps::Client; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
84691
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
82
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
74
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
143
|
|
|
7
|
2
|
|
|
2
|
|
1686
|
use Params::Validate qw/:all/; |
|
|
2
|
|
|
|
|
15480
|
|
|
|
2
|
|
|
|
|
493
|
|
|
8
|
2
|
|
|
2
|
|
2396
|
use LWP::UserAgent; |
|
|
2
|
|
|
|
|
132828
|
|
|
|
2
|
|
|
|
|
100
|
|
|
9
|
2
|
|
|
2
|
|
35
|
use Storable qw/nfreeze/; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
253
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
15
|
use constant PROTO_VERSION => 0.2; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
242
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Test::Chimps::Client - Send smoke test results to a server |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.05 |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This module simplifies the process of sending smoke test results |
|
28
|
|
|
|
|
|
|
(in the form of Cs) to a smoke server. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Test::Chimps::Client; |
|
31
|
|
|
|
|
|
|
use Test::TAP::Model::Visual; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
chdir "some/module/directory"; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $model = Test::TAP::Model::Visual->new_with_tests(glob("t/*.t")); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $client = Test::Chimps::Client->new( |
|
38
|
|
|
|
|
|
|
server => 'http://www.example.com/cgi-bin/smoke-server.pl', |
|
39
|
|
|
|
|
|
|
model => $model |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my ($status, $msg) = $client->send; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
if (! $status) { |
|
45
|
|
|
|
|
|
|
print "Error: $msg\n"; |
|
46
|
|
|
|
|
|
|
exit(1); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 new ARGS |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Creates a new Client object. ARGS is a hash whose valid keys are: |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * compress |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Optional. Does not currently work |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * model |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Mandatory. The value must be a C. These are the |
|
65
|
|
|
|
|
|
|
test results that will be submitted to the server. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item * report_variables |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Optional. A hashref of report variables and values to send to the |
|
70
|
|
|
|
|
|
|
server. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * server |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Mandatory. The URI of the server script to upload the model to. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
2
|
|
|
2
|
|
14
|
use base qw/Class::Accessor/; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
11108
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/model server compress report_variables/); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub new { |
|
85
|
1
|
|
|
1
|
1
|
469
|
my $class = shift; |
|
86
|
1
|
|
|
|
|
3
|
my $obj = bless {}, $class; |
|
87
|
1
|
|
|
|
|
6
|
$obj->_init(@_); |
|
88
|
1
|
|
|
|
|
3
|
return $obj; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _init { |
|
92
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
|
93
|
1
|
|
|
|
|
74
|
my %args = validate_with( |
|
94
|
|
|
|
|
|
|
params => \@_, |
|
95
|
|
|
|
|
|
|
called => 'The Test::Chimps::Client constructor', |
|
96
|
|
|
|
|
|
|
spec => { |
|
97
|
|
|
|
|
|
|
model => { isa => 'Test::TAP::Model' }, |
|
98
|
|
|
|
|
|
|
server => 1, |
|
99
|
|
|
|
|
|
|
compress => 0, |
|
100
|
|
|
|
|
|
|
report_variables => { |
|
101
|
|
|
|
|
|
|
optional => 1, |
|
102
|
|
|
|
|
|
|
type => HASHREF, |
|
103
|
|
|
|
|
|
|
default => {} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
); |
|
107
|
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
16
|
foreach my $key (keys %args) { |
|
109
|
4
|
|
|
|
|
26
|
$self->{$key} = $args{$key}; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 send |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Submit the specified model to the server. This function's return |
|
117
|
|
|
|
|
|
|
value is a list, the first of which indicates success or failure, |
|
118
|
|
|
|
|
|
|
and the second of which is an error string. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub send { |
|
123
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
|
126
|
0
|
|
|
|
|
|
$ua->agent("Test-Chimps-Client/" . PROTO_VERSION); |
|
127
|
0
|
|
|
|
|
|
$ua->env_proxy; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my %request = (upload => 1, version => PROTO_VERSION, |
|
130
|
|
|
|
|
|
|
model_structure => nfreeze($self->model->structure), |
|
131
|
|
|
|
|
|
|
report_variables => nfreeze($self->report_variables)); |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $resp = $ua->post($self->server => \%request); |
|
134
|
0
|
0
|
|
|
|
|
if($resp->is_success) { |
|
135
|
0
|
0
|
|
|
|
|
if($resp->content =~ /^ok/) { |
|
136
|
0
|
|
|
|
|
|
return (1, ''); |
|
137
|
|
|
|
|
|
|
} else { |
|
138
|
0
|
|
|
|
|
|
return (0, $resp->content); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} else { |
|
141
|
0
|
|
|
|
|
|
return (0, $resp->status_line); |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
There are read-only accessors for compress, model, |
|
148
|
|
|
|
|
|
|
report_variables, and server. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Zev Benjamin, C<< >> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 BUGS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
157
|
|
|
|
|
|
|
C, or through the web interface at |
|
158
|
|
|
|
|
|
|
L. |
|
159
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
160
|
|
|
|
|
|
|
your bug as I make changes. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SUPPORT |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
perldoc Test::Chimps::Client |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
You can also look for information at: |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=over 4 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * Mailing list |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Chimps has a mailman mailing list at |
|
175
|
|
|
|
|
|
|
L. You can subscribe via the web |
|
176
|
|
|
|
|
|
|
interface at |
|
177
|
|
|
|
|
|
|
L. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * Search CPAN |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Some code in this module is based on smokeserv-client.pl from the |
|
200
|
|
|
|
|
|
|
Pugs distribution. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Copyright 2006 Best Practical Solutions. |
|
205
|
|
|
|
|
|
|
Portions copyright 2005-2006 the Pugs project. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
208
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
|
213
|
|
|
|
|
|
|
|