line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Build::Smolder; |
2
|
3
|
|
|
3
|
|
30361
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
131
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
110
|
|
4
|
3
|
|
|
3
|
|
17
|
use base 'Module::Build::TAPArchive'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
2330
|
|
5
|
|
|
|
|
|
|
use WWW::Mechanize; |
6
|
|
|
|
|
|
|
use Carp qw(croak); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
9
|
|
|
|
|
|
|
__PACKAGE__->add_property('server'); |
10
|
|
|
|
|
|
|
__PACKAGE__->add_property('username'); |
11
|
|
|
|
|
|
|
__PACKAGE__->add_property('password'); |
12
|
|
|
|
|
|
|
__PACKAGE__->add_property('project_id'); |
13
|
|
|
|
|
|
|
__PACKAGE__->add_property('architecture'); |
14
|
|
|
|
|
|
|
__PACKAGE__->add_property('platform'); |
15
|
|
|
|
|
|
|
__PACKAGE__->add_property('tags'); |
16
|
|
|
|
|
|
|
__PACKAGE__->add_property('comments'); |
17
|
|
|
|
|
|
|
__PACKAGE__->add_property('use_existing_archive'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Module::Build::Smolder - Extra build targets for sending smoke tests to a Smolder server |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Easily add support for extra build targets to send TAP Archives to a Smolder server |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
In your Build.PL |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Module::Builder::Smolder; |
30
|
|
|
|
|
|
|
my $builder = Module::Builder::Smolder->new( |
31
|
|
|
|
|
|
|
... |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Now you get these build targets |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
]$ perl Build.PL |
37
|
|
|
|
|
|
|
]$ ./Build smolder ... |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NEW TARGETS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
The following build targets are provided: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 smolder |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Create a TAP archive and then send it to Smolder. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head3 Required Flags |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This target needs to know where to send the archive, so it needs the following options: |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item --server |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item --project_id |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
]$ ./Build smolder --server mysmolder.com --username foo --password s3cr3t --project_id 5 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 Optional Flags |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item --username |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The Smolder user uploading the report. If not specified it will be uploaded anonymously |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item --password |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item --archive_file |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Specify the file to store the archive |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item --architecture |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Name of the architecture for the report |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item --platform |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Name of the CPU platform |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item --tags |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Comma separated list of tags for this report |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item --comments |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Free form text to associate with the smoke report |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item --use_existing_archive |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
If you've already run the tests and created a TAP Archive and you just |
94
|
|
|
|
|
|
|
want to submit that one to Smolder again, use this flag so that it doesn't |
95
|
|
|
|
|
|
|
run the tests again. Really useful when troubleshooting. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub ACTION_smolder { |
102
|
|
|
|
|
|
|
my $self = shift; |
103
|
|
|
|
|
|
|
my $p = $self->{properties}; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# make sure we have the important options |
106
|
|
|
|
|
|
|
foreach my $opt qw(server project_id) { |
107
|
|
|
|
|
|
|
croak "Required option --$opt needs to be set" unless $p->{$opt}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# if we have --username then we need --password |
111
|
|
|
|
|
|
|
croak "You need to specify --password if you are giving a --username" |
112
|
|
|
|
|
|
|
if $p->{username} && !$p->{password}; |
113
|
|
|
|
|
|
|
croak "You need to specify --username if you are giving a --password" |
114
|
|
|
|
|
|
|
if $p->{password} && !$p->{username}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# make sure our archive_file is there and we can use it |
117
|
|
|
|
|
|
|
my $file = $p->{archive_file}; |
118
|
|
|
|
|
|
|
if($file ) { |
119
|
|
|
|
|
|
|
if(!-e $file) { |
120
|
|
|
|
|
|
|
croak "Archive file $file does not exist!"; |
121
|
|
|
|
|
|
|
} elsif(!-r $file) { |
122
|
|
|
|
|
|
|
croak "Archive file $file is not readable!"; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} else { |
125
|
|
|
|
|
|
|
croak "No archive_file was created. Something is really wrong!"; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$self->depends_on('code'); |
129
|
|
|
|
|
|
|
$self->depends_on('test_archive') unless $p->{use_existing_archive}; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# try and reach the smolder server |
132
|
|
|
|
|
|
|
my $server = $p->{server}; |
133
|
|
|
|
|
|
|
print "Trying to reach Smolder server at $server.\n"; |
134
|
|
|
|
|
|
|
my $mech = WWW::Mechanize->new(); |
135
|
|
|
|
|
|
|
my $base_url = "http://$server/app"; |
136
|
|
|
|
|
|
|
eval { $mech->get($base_url) }; |
137
|
|
|
|
|
|
|
unless ($mech->status eq '200') { |
138
|
|
|
|
|
|
|
warn "Could not reach $server successfully. Received status " . $mech->status . "\n"; |
139
|
|
|
|
|
|
|
exit(1); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# now login if we need to |
143
|
|
|
|
|
|
|
my $user = $p->{username}; |
144
|
|
|
|
|
|
|
my $pw = $p->{password}; |
145
|
|
|
|
|
|
|
my ($logged_in, $content); |
146
|
|
|
|
|
|
|
if( $user && $pw ) { |
147
|
|
|
|
|
|
|
print "Trying to login with username '$user'.\n"; |
148
|
|
|
|
|
|
|
$mech->get($base_url . '/public_auth/login'); |
149
|
|
|
|
|
|
|
my $form = $mech->form_name('login'); |
150
|
|
|
|
|
|
|
if ($mech->status ne '200' || !$form) { |
151
|
|
|
|
|
|
|
warn "Could not reach Smolder login form. Are you sure $server is a Smolder server?\n"; |
152
|
|
|
|
|
|
|
exit(1); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
$mech->set_fields( |
155
|
|
|
|
|
|
|
username => $user, |
156
|
|
|
|
|
|
|
password => $pw, |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
$mech->submit(); |
159
|
|
|
|
|
|
|
$content = $mech->content; |
160
|
|
|
|
|
|
|
if ($mech->status ne '200' || $content !~ /Welcome \Q$user\E/) { |
161
|
|
|
|
|
|
|
warn "Could not login with username '$user' and password '$pw'!\n"; |
162
|
|
|
|
|
|
|
exit(1); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
$logged_in = 1; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# now go to the add-smoke-report page for this project |
168
|
|
|
|
|
|
|
my $project_id = $p->{project_id}; |
169
|
|
|
|
|
|
|
print "Adding smoke report to project #$project_id.\n"; |
170
|
|
|
|
|
|
|
my $url = "$base_url/" . ($logged_in ? 'developer' : 'public') . "_projects/add_report/$project_id"; |
171
|
|
|
|
|
|
|
$mech->get($url); |
172
|
|
|
|
|
|
|
$content = $mech->content; |
173
|
|
|
|
|
|
|
if ($mech->status ne '200' || $content !~ /New Smoke Report/) { |
174
|
|
|
|
|
|
|
if( $content =~ /unauthorized/i ) { |
175
|
|
|
|
|
|
|
warn "You are not authorized to submit reports to this project!\n"; |
176
|
|
|
|
|
|
|
} elsif( $content =~ /not a public project/i ) { |
177
|
|
|
|
|
|
|
warn "This is not a public project. You need to specify --username!\n"; |
178
|
|
|
|
|
|
|
} elsif( $content =~ /not allow anonymous/i ) { |
179
|
|
|
|
|
|
|
warn "This project does not allow anonymouse reports!\n"; |
180
|
|
|
|
|
|
|
} else { |
181
|
|
|
|
|
|
|
warn "Could not reach the Add Smoke Report form!\n"; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
exit(1); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
$mech->form_name('add_report'); |
186
|
|
|
|
|
|
|
my %fields = (report_file => $file); |
187
|
|
|
|
|
|
|
$fields{platform} = $p->{platform} if ($p->{platform}); |
188
|
|
|
|
|
|
|
$fields{architecture} = $p->{architecture} if ($p->{architecture}); |
189
|
|
|
|
|
|
|
$fields{tags} = $p->{tags} if ($p->{tags}); |
190
|
|
|
|
|
|
|
$fields{comments} = $p->{comments} if ($p->{comments}); |
191
|
|
|
|
|
|
|
$mech->set_fields(%fields); |
192
|
|
|
|
|
|
|
$mech->submit(); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$content = $mech->content; |
195
|
|
|
|
|
|
|
if ($mech->status ne '200' || $content !~ /Recent Smoke Reports/) { |
196
|
|
|
|
|
|
|
warn "Could not upload smoke report with the given information!\n"; |
197
|
|
|
|
|
|
|
exit(1); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
if( $content =~ /#(\d+) Added/ ) { |
200
|
|
|
|
|
|
|
my $report_id = $1; |
201
|
|
|
|
|
|
|
print "Smoke Report successfully uploaded to Smolder server $server as #$report_id.\n"; |
202
|
|
|
|
|
|
|
} else { |
203
|
|
|
|
|
|
|
print "Smoething strange happened. " . "We're not sure if the report was successfully uploaded or not.\n"; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 AUTHOR |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Michael Peters, C<< >> |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 BUGS |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
215
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
216
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 SUPPORT |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
perldoc Module::Build::Smolder |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
You can also look for information at: |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
L |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * CPAN Ratings |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item * Search CPAN |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=back |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Copyright 2009 Michael Peters, all rights reserved. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
251
|
|
|
|
|
|
|
under the same terms as Perl itself. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
1; |