Skip to content

Commit

Permalink
handle $aborted with a bit more logic
Browse files Browse the repository at this point in the history
trying to preserve the functionality though
  • Loading branch information
coolo committed Dec 11, 2014
1 parent 029d3a3 commit b2470e4
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions script/worker
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ sub save_vars($) {
}

sub stop_job {
my $result = "ok";
my $result = "passed";
$result = $aborted if $aborted;

my $name = $job->{'settings'}->{'NAME'};
Expand All @@ -441,7 +441,8 @@ sub stop_job {
close($log);
}

if (!$aborted || !($aborted eq 'quit' && $aborted eq 'abort')) {
$aborted ||= '';
if ($aborted ne 'quit' && $aborted ne 'abort') {
# collect uploaded logs
my @uploaded_logfiles = <$pooldir/ulogs/*>;
mkdir("$testresults/ulogs/");
Expand All @@ -468,23 +469,24 @@ sub stop_job {

# if there's no results.json start.pl probably died early, e.g. due to configuration
# problem. Release the job so another worker may grab it.
my $overall = results_overall("$testresults/results.json");
$result = $overall if !$aborted && $overall;
my $overall = results_overall("$testresults/results.json") || '';
# FIXME: this needs improvement
if ($result eq 'ok') {
$result = 'passed';
if ($overall eq 'ok') {
$overall = 'passed';
}
elsif ($result eq 'fail') {
$result = 'failed';
elsif ($overall eq 'fail') {
$overall = 'failed';
}
else {
$result = 'incomplete';
$overall = 'incomplete';
}
if (($aborted||'') eq 'obsolete') {
$result = $overall if !$aborted && $overall;

if ($aborted eq 'obsolete') {
printf "setting job %d to $result and obsoleted\n", $job->{'id'};
api_call('post', 'jobs/'.$job->{'id'}.'/set_done', {result => $result, newbuild => 1});
}
elsif (($aborted||'') eq 'cancel' || $overall) {
elsif ($aborted eq 'cancel' || $overall) {
printf "setting job %d to $result\n", $job->{'id'};
api_call('post', 'jobs/'.$job->{'id'}.'/set_done', {result => $result});
}
Expand Down Expand Up @@ -741,7 +743,7 @@ sub main(){
die "huh? wrong child?\n" unless $pid == $worker->{pid};
if ($?) {
warn "child $pid died with exit status $?\n";
$aborted = "died" unless $aborted;
$aborted ||= "died";
}
stop_job;
}
Expand Down

0 comments on commit b2470e4

Please sign in to comment.