testbot: Capture the task scripts Perl errors in the task's generic error log.
Francois Gouget
fgouget at codeweavers.com
Tue Dec 11 05:07:53 CST 2012
Also simplify the fork()+exec() code a bit.
---
testbot/lib/WineTestBot/Tasks.pm | 56 +++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index adba173..79622de 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -80,35 +80,53 @@ sub Run
$self->Status("running");
$self->Save();
+ my $Job = WineTestBot::Jobs::CreateJobs()->GetItem($JobId);
+ my $Step = $Job->Steps->GetItem($StepNo);
+ my $RunScript;
+ if ($Step->Type eq "build")
+ {
+ $RunScript = "RunBuild.pl";
+ }
+ elsif ($Step->Type eq "reconfig")
+ {
+ $RunScript = "RunReconfig.pl";
+ }
+ else
+ {
+ $RunScript = "RunTask.pl";
+ }
+ $Step = undef;
+ $Job = undef;
+
$self->GetBackEnd()->PrepareForFork();
my $Pid = fork;
- if (defined($Pid) && ! $Pid)
+ if (!defined $Pid)
{
- my $Job = WineTestBot::Jobs::CreateJobs()->GetItem($JobId);
- my $Step = $Job->Steps->GetItem($StepNo);
- my $RunScript;
- if ($Step->Type eq "build")
- {
- $RunScript = "$BinDir/${ProjectName}RunBuild.pl";
- }
- elsif ($Step->Type eq "reconfig")
+ return "Unable to fork for ${ProjectName}$RunScript: $!";
+ }
+ elsif (!$Pid)
+ {
+ # Capture Perl errors in the task's generic error log
+ my $TaskDir = "$DataDir/jobs/$JobId/$StepNo/" . $self->No;
+ mkdir $TaskDir;
+ unlink "$TaskDir/err"; # truncate the log since this is a new run
+ if (open(STDERR, ">>", "$TaskDir/err"))
{
- $RunScript = "$BinDir/${ProjectName}RunReconfig.pl";
+ # Make sure stderr still flushes after each print
+ my $tmp=select(STDERR);
+ $| = 1;
+ select($tmp);
}
else
{
- $RunScript = "$BinDir/${ProjectName}RunTask.pl";
+ LogMsg "unable to redirect stderr to '$TaskDir/err'\n";
}
- $Step = undef;
- $Job = undef;
$ENV{PATH} = "/usr/bin:/bin";
delete $ENV{ENV};
- exec($RunScript, $JobId, $StepNo, $self->No);
- exit;
- }
- if (! defined($Pid))
- {
- return "Unable to start child process: $!";
+ exec("$BinDir/${ProjectName}$RunScript", $JobId, $StepNo, $self->No) or
+ require WineTestBot::Log;
+ WineTestBot::Log::LogMsg "Unable to exec ${ProjectName}$RunScript: $!\n";
+ exit(1);
}
$self->ChildPid($Pid);
--
1.7.10.4
More information about the wine-patches
mailing list