| 1 |
|
|---|
| 2 |
use warnings; |
|---|
| 3 |
use strict; |
|---|
| 4 |
use File::Path; |
|---|
| 5 |
use File::Temp qw(tempdir); |
|---|
| 6 |
use LWP::Simple; |
|---|
| 7 |
use YAML; |
|---|
| 8 |
|
|---|
| 9 |
our $lockdir = "$ENV{HOME}/.plagger-smoke.lock"; |
|---|
| 10 |
mkdir $lockdir, 0777 or die "Other process is running!\n"; |
|---|
| 11 |
our $rmdir = 1; |
|---|
| 12 |
|
|---|
| 13 |
our $repo = "http://svn.bulknews.net/repos/plagger"; |
|---|
| 14 |
our $trac = "http://plagger.org/trac"; |
|---|
| 15 |
our $file = "$ENV{HOME}/.plagger-smoke.yml"; |
|---|
| 16 |
|
|---|
| 17 |
my $config = eval { YAML::LoadFile($file) } || {}; |
|---|
| 18 |
my $current = get_current($repo) or die "Can't get Revision from $repo"; |
|---|
| 19 |
|
|---|
| 20 |
$config->{revision} ||= $current - 1; |
|---|
| 21 |
|
|---|
| 22 |
my $run; |
|---|
| 23 |
while (++$config->{revision} <= $current) { |
|---|
| 24 |
my $branch = get_branch($config->{revision}); |
|---|
| 25 |
run_chimps($config->{revision}, $branch); |
|---|
| 26 |
$run++; |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
$config->{revision} = $current; |
|---|
| 30 |
YAML::DumpFile($file, $config) if $run; |
|---|
| 31 |
|
|---|
| 32 |
END { rmdir $lockdir if $rmdir && -e $lockdir }; |
|---|
| 33 |
|
|---|
| 34 |
sub run_chimps { |
|---|
| 35 |
my($revision, $branch) = @_; |
|---|
| 36 |
|
|---|
| 37 |
my $workdir = tempdir(CLEANUP => 1); |
|---|
| 38 |
my $checkout = "plagger-r$revision"; |
|---|
| 39 |
|
|---|
| 40 |
chdir $workdir; |
|---|
| 41 |
|
|---|
| 42 |
if (-e $checkout) { |
|---|
| 43 |
die "$workdir/$checkout exists. Remove it first"; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
warn "Testing r$revision on $branch\n"; |
|---|
| 47 |
|
|---|
| 48 |
delete $ENV{LANG}; |
|---|
| 49 |
system("svn co -r $revision $repo/$branch/plagger $checkout"); |
|---|
| 50 |
chdir $checkout; |
|---|
| 51 |
|
|---|
| 52 |
system("perl Makefile.PL --skip"); |
|---|
| 53 |
|
|---|
| 54 |
warn "Running chimps-client"; |
|---|
| 55 |
system("tools/chimps-client.pl"); |
|---|
| 56 |
warn "Done."; |
|---|
| 57 |
|
|---|
| 58 |
chdir ".."; |
|---|
| 59 |
rmtree("$workdir/$checkout"); |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
sub get_current { |
|---|
| 63 |
my $repo = shift; |
|---|
| 64 |
my $html = LWP::Simple::get($repo); |
|---|
| 65 |
$html =~ /Revision (\d+):/ and return $1; |
|---|
| 66 |
return; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
sub get_branch { |
|---|
| 70 |
my $revision = shift; |
|---|
| 71 |
my $diff = LWP::Simple::get("$trac/changeset/$revision?format=diff"); |
|---|
| 72 |
$diff =~ m!^Index: (branches/[^/]+|trunk)/! and return $1; |
|---|
| 73 |
return "trunk"; |
|---|
| 74 |
} |
|---|