Module: tools
Branch: master
Commit: 006258002477b9b2bc86f03e5641eefc34d6ec32
URL: http://source.winehq.org/git/tools.git/?a=commit;h=006258002477b9b2bc86f03e…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Oct 11 16:18:03 2017 +0200
testbot: Improve the Jobs error handling and documentation.
Specifically in the UpdateStatus(), Cancel() and Restart() methods.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/WineTestBot/Jobs.pm | 50 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm
index 9976794..c26ff92 100644
--- a/testbot/lib/WineTestBot/Jobs.pm
+++ b/testbot/lib/WineTestBot/Jobs.pm
@@ -123,6 +123,8 @@ Updates the status of this job and of its steps and tasks. Part of this means
checking for failed builds and skipping the subsequent tasks, or detecting
dead child processes.
+Returns the updated status.
+
=back
=cut
@@ -183,9 +185,27 @@ sub UpdateStatus($)
return $Status;
}
+=pod
+=over 12
+
+=item C<Cancel()>
+
+Cancels the Job, preserving existing results.
+
+More precisely, goes through all of that Job's 'queued' and 'running' tasks,
+killing all the running ones and marking them, and all the queued tasks, as
+'skipped' so they will not be run. The overall Job status will be 'canceled'
+unless it was completed already.
+
+Returns undef if successful, the error message otherwise.
+
+=back
+=cut
+
sub Cancel($)
{
my ($self) = @_;
+ my $ErrMessage;
my $Steps = $self->Steps;
$Steps->AddFilter("Status", ["queued", "running"]);
@@ -198,7 +218,8 @@ sub Cancel($)
if ($Task->Status eq "queued")
{
$Task->Status("skipped");
- $Task->Save();
+ my ($EProperty, $EMessage) = $Task->Save();
+ $ErrMessage ||= "$EMessage ($EProperty)" if ($EMessage);
}
elsif (defined $Task->ChildPid)
{
@@ -207,20 +228,38 @@ sub Cancel($)
kill("TERM", $Task->ChildPid);
$Task->Status("canceled");
$Task->ChildPid(undef);
- $Task->Save();
+ my ($EProperty, $EMessage) = $Task->Save();
+ $ErrMessage ||= "$EMessage ($EProperty)" if ($EMessage);
my $VM = $Task->VM;
$VM->Status('dirty');
- $VM->Save();
+ ($EProperty, $EMessage) = $VM->Save();
+ $ErrMessage ||= "$EMessage ($EProperty)" if ($EMessage);
}
}
}
# Let UpdateStatus() handle updating the overall job status
$self->UpdateStatus();
- return undef;
+ return $ErrMessage;
}
+=pod
+=over 12
+
+=item C<Restart()>
+
+Restarts the Job from scratch.
+
+More precisely, if the Job is not 'queued' or 'running', goes through all of
+its tasks and marks them all as 'queued', deleting any existing result in the
+process.
+
+Returns undef if successful, the error message otherwise.
+
+=back
+=cut
+
sub Restart($)
{
my ($self) = @_;
@@ -259,7 +298,8 @@ sub Restart($)
$self->Status("queued");
$self->Submitted(time);
$self->Ended(undef);
- $self->Save(); # Save it all
+ my ($ErrProperty, $ErrMessage) = $self->Save(); # Save it all
+ return "$ErrMessage ($ErrProperty)" if ($ErrMessage);
return undef;
}
Module: tools
Branch: master
Commit: 1d497afe25f3f633134e2a491b65af62cc0aa83e
URL: http://source.winehq.org/git/tools.git/?a=commit;h=1d497afe25f3f633134e2a49…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Oct 11 16:15:30 2017 +0200
testbot: Fix Tasks to not use WineTestBot::Log.
The perl modules should return error messages to the callers and let
them deal with logging. So don't import WineTestBot::Log globally to
ensure any logging really is deliberate.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/WineTestBot/Tasks.pm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index 3dd5f13..401e275 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -40,7 +40,6 @@ use WineTestBot::Config;
use WineTestBot::Jobs;
use WineTestBot::Steps;
use WineTestBot::WineTestBotObjects;
-use WineTestBot::Log;
use vars qw(@ISA @EXPORT);
@@ -109,6 +108,7 @@ sub Run($$)
}
elsif (!$Pid)
{
+ require WineTestBot::Log;
# Capture Perl errors in the task's generic error log
my ($JobId, $StepNo, $TaskNo) = @{$self->GetMasterKey()};
my $TaskDir = "$DataDir/jobs/$JobId/$StepNo/$TaskNo";
@@ -124,12 +124,11 @@ sub Run($$)
}
else
{
- LogMsg "unable to redirect stderr to '$TaskDir/err': $!\n";
+ WineTestBot::Log::LogMsg("unable to redirect stderr to '$TaskDir/err': $!\n");
}
$ENV{PATH} = "/usr/bin:/bin";
delete $ENV{ENV};
exec("$BinDir/${ProjectName}$RunScript", "--log-only", $JobId, $StepNo, $TaskNo) or
- require WineTestBot::Log;
WineTestBot::Log::LogMsg("Unable to exec ${ProjectName}$RunScript: $!\n");
exit(1);
}
@@ -173,7 +172,8 @@ sub UpdateStatus($$)
umask($OldUMask);
# This probably indicates a bug in the task script.
# Don't requeue the task to avoid an infinite loop.
- LogMsg "Child process for task $JobId/$StepNo/$TaskNo died unexpectedly\n";
+ require WineTestBot::Log;
+ WineTestBot::Log::LogMsg("Child process for task $JobId/$StepNo/$TaskNo died unexpectedly\n");
$self->Status("boterror");
$Status = "boterror";