[1/2b] testbot/lib: Pass the Step object to Task::Run() so it does not have to look it up.

Francois Gouget fgouget at codeweavers.com
Tue May 6 05:41:31 CDT 2014


---
 testbot/lib/WineTestBot/Jobs.pm  |  4 ++--
 testbot/lib/WineTestBot/Tasks.pm | 16 ++++++----------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm
index 8e36a32..b042bea 100644
--- a/testbot/lib/WineTestBot/Jobs.pm
+++ b/testbot/lib/WineTestBot/Jobs.pm
@@ -1,5 +1,5 @@
 # Copyright 2009 Ge van Geldorp
-# Copyright 2012 Francois Gouget
+# Copyright 2012-2014 Francois Gouget
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -511,7 +511,7 @@ sub ScheduleOnHost($$$)
           my ($ErrProperty, $ErrMessage) = $VM->Save();
           return $ErrMessage if (defined $ErrMessage);
 
-          $ErrMessage = $Task->Run($Job->Id, $Step->No);
+          $ErrMessage = $Task->Run($Step);
           return $ErrMessage if (defined $ErrMessage);
 
           $Job->UpdateStatus();
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index 28e0727..fd848f2 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -1,5 +1,5 @@
 # Copyright 2009 Ge van Geldorp
-# Copyright 2012 Francois Gouget
+# Copyright 2012-2014 Francois Gouget
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -72,16 +72,13 @@ Where $Type corresponds to the Task's type.
 =back
 =cut
 
-sub Run
+sub Run($$)
 {
-  my $self = shift;
-  my ($JobId, $StepNo) = @_;
+  my ($self, $Step) = @_;
 
   $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")
   {
@@ -95,8 +92,6 @@ sub Run
   {
     $RunScript = "RunTask.pl";
   }
-  $Step = undef;
-  $Job = undef;
 
   $self->GetBackEnd()->PrepareForFork();
   my $Pid = fork;
@@ -107,7 +102,8 @@ sub Run
   elsif (!$Pid)
   {
     # Capture Perl errors in the task's generic error log
-    my $TaskDir = "$DataDir/jobs/$JobId/$StepNo/" . $self->No;
+    my ($JobId, $StepNo, $TaskNo) = @{$self->GetMasterKey()};
+    my $TaskDir = "$DataDir/jobs/$JobId/$StepNo/$TaskNo";
     mkdir $TaskDir;
     unlink "$TaskDir/err"; # truncate the log since this is a new run
     if (open(STDERR, ">>", "$TaskDir/err"))
@@ -123,7 +119,7 @@ sub Run
     }
     $ENV{PATH} = "/usr/bin:/bin";
     delete $ENV{ENV};
-    exec("$BinDir/${ProjectName}$RunScript", $JobId, $StepNo, $self->No) or
+    exec("$BinDir/${ProjectName}$RunScript", $JobId, $StepNo, $TaskNo) or
     require WineTestBot::Log;
     WineTestBot::Log::LogMsg("Unable to exec ${ProjectName}$RunScript: $!\n");
     exit(1);
-- 
2.0.0.rc0




More information about the wine-patches mailing list