| 1 |
|
|---|
| 2 |
use strict; |
|---|
| 3 |
use warnings; |
|---|
| 4 |
|
|---|
| 5 |
use FindBin; |
|---|
| 6 |
use lib "$FindBin::Bin/../lib"; |
|---|
| 7 |
|
|---|
| 8 |
use Config; |
|---|
| 9 |
use File::Spec; |
|---|
| 10 |
use Test::Chimps::Client; |
|---|
| 11 |
use Test::TAP::Model::Visual; |
|---|
| 12 |
|
|---|
| 13 |
chdir "$FindBin::Bin/.."; |
|---|
| 14 |
check_dependencies(); |
|---|
| 15 |
|
|---|
| 16 |
my @tests = map glob, qw(t/*.t t/*/*.t t/*/*/*.t); |
|---|
| 17 |
my $start = time; |
|---|
| 18 |
my $model = Test::TAP::Model::Visual->new_with_tests(@tests); |
|---|
| 19 |
|
|---|
| 20 |
my $client = Test::Chimps::Client->new( |
|---|
| 21 |
server => 'http://plagger.org/chimps-server', |
|---|
| 22 |
model => $model, |
|---|
| 23 |
report_variables => { |
|---|
| 24 |
archname => $Config{archname}, |
|---|
| 25 |
committer => $ENV{USER} || $ENV{USERNAME}, |
|---|
| 26 |
osname => $Config{osname}, |
|---|
| 27 |
osvers => $Config{osvers}, |
|---|
| 28 |
project => 'Plagger', |
|---|
| 29 |
duration => time - $start, |
|---|
| 30 |
revision => get_revision(), |
|---|
| 31 |
}, |
|---|
| 32 |
); |
|---|
| 33 |
|
|---|
| 34 |
my ($status, $msg) = $client->send; |
|---|
| 35 |
if (! $status) { |
|---|
| 36 |
print "Error: $msg\n"; |
|---|
| 37 |
exit(1); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
sub get_revision { |
|---|
| 41 |
return |
|---|
| 42 |
extract_revision('svk', 'svk info', qr/Mirrored From: .*Rev\. (\d+)/) || |
|---|
| 43 |
extract_revision('svn', 'svn info', qr/Revision: (\d+)/) || |
|---|
| 44 |
extract_svn_revision('.svn/entries') || |
|---|
| 45 |
'unknown'; |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
sub extract_revision { |
|---|
| 49 |
my($cmd, $command, $re) = @_; |
|---|
| 50 |
|
|---|
| 51 |
return unless has_command($cmd); |
|---|
| 52 |
|
|---|
| 53 |
my $out = qx($command) or return; |
|---|
| 54 |
$out =~ /$re/; |
|---|
| 55 |
return $1; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
sub has_command { |
|---|
| 59 |
my $cmd = shift; |
|---|
| 60 |
grep { -e File::Spec->catfile($_, $cmd) } split /:/, $ENV{PATH}; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
sub extract_svn_revision { |
|---|
| 64 |
my $file = shift; |
|---|
| 65 |
open my($fh), $file or return; |
|---|
| 66 |
while (<$fh>) { |
|---|
| 67 |
/revision="(\d+)"/ and return $1; |
|---|
| 68 |
} |
|---|
| 69 |
return; |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
sub check_dependencies { |
|---|
| 73 |
warn "Checking dependencies ...\n"; |
|---|
| 74 |
my $out = `$Config{perlpath} tools/check-dependencies.pl`; |
|---|
| 75 |
|
|---|
| 76 |
if (my @missing = $out =~ /^(.*missing \(required\))$/mg) { |
|---|
| 77 |
die "You need to install dependencies first.\n", join("\n", @missing) . "\n"; |
|---|
| 78 |
} |
|---|
| 79 |
warn "Done.\n"; |
|---|
| 80 |
} |
|---|