Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
submit reports for failure and success
(to localhost for now)
  • Loading branch information
FROGGS committed Oct 26, 2014
1 parent 98ea6ec commit 3f598d3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
6 changes: 1 addition & 5 deletions bin/panda
Expand Up @@ -3,7 +3,6 @@ use Shell::Command;
use Panda;
use Panda::Ecosystem;
use Panda::App;
use Panda::Reporter;

# default opts for MAIN
if %*ENV<PANDA_DEFAULT_OPTS> {
Expand All @@ -19,10 +18,7 @@ multi MAIN ('install', *@modules, Bool :$notests, Bool :$nodeps) {
for @modules -> $x {
try {
$panda.resolve($x, :$notests, :$nodeps, :action<install>);
CATCH { when X::Panda {
'test-report'.IO.spurt: Panda::Reporter.new( :bone($_.bone) ).to-json if $_.bone;
say $_.message
} }
CATCH { when X::Panda { say $_.message } }
};
}
}
Expand Down
1 change: 1 addition & 0 deletions bootstrap.pl
Expand Up @@ -7,6 +7,7 @@ BEGIN
use lib 'ext/File__Find/lib/';
use lib 'ext/Shell__Command/lib/';
use Shell::Command;
%*ENV<PANDA_SUBMIT_TESTREPORTS>:delete;

say '==> Bootstrapping Panda';

Expand Down
3 changes: 3 additions & 0 deletions lib/Panda.pm
Expand Up @@ -4,6 +4,7 @@ use Panda::Fetcher;
use Panda::Builder;
use Panda::Tester;
use Panda::Installer;
use Panda::Reporter;
use Shell::Command;
use JSON::Tiny;

Expand Down Expand Up @@ -129,11 +130,13 @@ class Panda {
!! Panda::Project::State::installed;
$.ecosystem.project-set-state($bone, $s);
self.announce('success', $bone);
Panda::Reporter.new( :$bone ).submit;

chdir $cwd;
rm_rf $dir;

CATCH {
Panda::Reporter.new( :$bone ).submit;
chdir $cwd;
rm_rf $dir;
}
Expand Down
22 changes: 22 additions & 0 deletions lib/Panda/Reporter.pm
Expand Up @@ -2,6 +2,28 @@ class Panda::Reporter;

has $.bone is rw;

method submit {
if %*ENV<PANDA_SUBMIT_TESTREPORTS> {
my $s;
my $to-send = '';
if %*ENV<http_proxy> {
my ($host, $port) = %*ENV<http_proxy>.split('/').[2].split(':');
$s = IO::Socket::INET.new( :$host, :port($port.Int) );
$to-send = "POST http://127.0.0.1:3000/report HTTP/1.1\nHost: localhost\nConnection: Close";
}
else {
$s = IO::Socket::INET.new(:host<127.0.0.1>, :port(3000));
$to-send = "POST /report HTTP/1.0";
}

$s.send($to-send ~ "\nContent-Type: application/json\r\n\r\n" ~ self.to-json);

CATCH {
die "Could not submit test report: {$_.message}"
}
}
}

method to-json {
to-json {
:name($!bone.name),
Expand Down
1 change: 1 addition & 0 deletions rebootstrap.pl
Expand Up @@ -7,6 +7,7 @@ BEGIN
use lib 'ext/File__Find/lib/';
use lib 'ext/Shell__Command/lib';
use Shell::Command;
%*ENV<PANDA_SUBMIT_TESTREPORTS>:delete;

# Find old state file
my ($prefix, $state-file);
Expand Down

0 comments on commit 3f598d3

Please sign in to comment.