Francois Gouget : testbot/bin: Remove some global variables.

Alexandre Julliard julliard at winehq.org
Fri Jun 15 12:37:10 CDT 2018


Module: tools
Branch: master
Commit: f57106829dd57941cc69088c1be3885a0fee3a0a
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=f57106829dd57941cc69088c1be3885a0fee3a0a

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Fri Jun 15 11:56:28 2018 +0200

testbot/bin: Remove some global variables.

The variable names are longer than the values they replace and
make the code less readable due to the extra indirection.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/WineRunBuild.pl    | 15 ++++++---------
 testbot/bin/WineRunReconfig.pl | 15 ++++++---------
 testbot/bin/WineRunTask.pl     | 26 +++++++++++---------------
 3 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 96d9321..eab33bc 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -162,15 +162,12 @@ if (!defined $Task)
   Error "Step $StepNo task $TaskNo of job $JobId does not exist\n";
   exit 1;
 }
-
 my $OldUMask = umask(002);
 my $TaskDir = $Task->CreateDir();
 umask($OldUMask);
-my $FullLogFileName = "$TaskDir/log";
-my $FullErrFileName = "$TaskDir/err";
-
 my $VM = $Task->VM;
 
+
 my $Start = Time();
 LogMsg "Task $JobId/$StepNo/$TaskNo started\n";
 
@@ -185,14 +182,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", $FullErrFileName))
+  if (open(my $ErrFile, ">>", "$TaskDir/err"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open '$FullErrFileName' for writing: $!\n";
+    Error "Unable to open 'err' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -391,10 +388,10 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
   }
 }
 
-Debug(Elapsed($Start), " Retrieving the build log to '$FullLogFileName'\n");
-if ($TA->GetFile("Build.log", $FullLogFileName))
+Debug(Elapsed($Start), " Retrieving 'Build.log'\n");
+if ($TA->GetFile("Build.log", "$TaskDir/log"))
 {
-  if (open(my $LogFile, "<", $FullLogFileName))
+  if (open(my $LogFile, "<", "$TaskDir/log"))
   {
     # Collect and analyze the 'Build:' status line(s)
     $ErrMessage ||= "";
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 4fb34a0..e7b447e 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -161,14 +161,11 @@ if (!defined $Task)
   Error "Step $StepNo task $TaskNo of job $JobId does not exist\n";
   exit 1;
 }
-
 my $OldUMask = umask(002);
 my $TaskDir = $Task->CreateDir();
 umask($OldUMask);
-
 my $VM = $Task->VM;
-my $FullLogFileName = "$TaskDir/log";
-my $FullErrFileName = "$TaskDir/err";
+
 
 my $Start = Time();
 LogMsg "Task $JobId/$StepNo/$TaskNo started\n";
@@ -184,14 +181,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", $FullErrFileName))
+  if (open(my $ErrFile, ">>", "$TaskDir/err"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open '$FullErrFileName' for writing: $!\n";
+    Error "Unable to open 'err' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -373,10 +370,10 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
   }
 }
 
-Debug(Elapsed($Start), " Retrieving the reconfig log to '$FullLogFileName'\n");
-if ($TA->GetFile("Reconfig.log", $FullLogFileName))
+Debug(Elapsed($Start), " Retrieving 'Reconfig.log'\n");
+if ($TA->GetFile("Reconfig.log", "$TaskDir/log"))
 {
-  if (open(my $LogFile, "<", $FullLogFileName))
+  if (open(my $LogFile, "<", "$TaskDir/log"))
   {
     # Collect and analyze the 'Reconfig:' status line(s).
     my $LogErrors;
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index 3cf37c2..b428069 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -191,17 +191,13 @@ if (!defined $Task)
   Error "Step $StepNo task $TaskNo of job $JobId does not exist\n";
   exit 1;
 }
-
 my $OldUMask = umask(002);
 my $TaskDir = $Task->CreateDir();
 umask($OldUMask);
-my $FullLogFileName = "$TaskDir/log";
-my $FullErrFileName = "$TaskDir/err";
-my $FullScreenshotFileName = "$TaskDir/screenshot.png";
-
 my $VM = $Task->VM;
 my $RptFileName = $VM->Name . ".rpt";
 
+
 my $Start = Time();
 LogMsg "Task $JobId/$StepNo/$TaskNo started\n";
 
@@ -216,14 +212,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", $FullErrFileName))
+  if (open(my $ErrFile, ">>", "$TaskDir/err"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open '$FullErrFileName' for writing: $!\n";
+    Error "Unable to open 'err' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -237,7 +233,7 @@ sub WrapUpAndExit($;$$$)
                  $Timeout ? "timeout" : "";
 
   Debug(Elapsed($Start), " Taking a screenshot\n");
-  TakeScreenshot($VM, $FullScreenshotFileName);
+  TakeScreenshot($VM, "$TaskDir/screenshot.png");
 
   my $Tries = $Task->TestFailures || 0;
   if ($Retry)
@@ -299,9 +295,9 @@ sub WrapUpAndExit($;$$$)
     my $LatestBaseName = join("", "$DataDir/latest/", $Task->VM->Name, "_",
                               $Step->FileType eq "exe64" ? "64" : "32");
     unlink("$LatestBaseName.log");
-    link($FullLogFileName, "$LatestBaseName.log") if (-f $FullLogFileName);
+    link("$TaskDir/log", "$LatestBaseName.log") if (-f "$TaskDir/log");
     unlink("$LatestBaseName.err");
-    link($FullErrFileName, "$LatestBaseName.err") if (-f $FullErrFileName);
+    link("$TaskDir/err", "$LatestBaseName.err") if (-f "$TaskDir/err");
   }
 
   my $Result = $VM->Name .": ". $VM->Status ." Status: $Status Failures: ". (defined $TestFailures ? $TestFailures : "unset");
@@ -515,11 +511,11 @@ if (!defined $TA->Wait($Pid, $Timeout, $Keepalive))
 }
 
 my $TimedOut;
-Debug(Elapsed($Start), " Retrieving the report file to '$FullLogFileName'\n");
-if ($TA->GetFile($RptFileName, $FullLogFileName))
+Debug(Elapsed($Start), " Retrieving the report file to 'log'\n");
+if ($TA->GetFile($RptFileName, "$TaskDir/log"))
 {
-  chmod 0664, $FullLogFileName;
-  if (open(my $LogFile, "<", $FullLogFileName))
+  chmod 0664, "$TaskDir/log";
+  if (open(my $LogFile, "<", "$TaskDir/log"))
   {
     # There is more than one test unit when running the full test suite so keep
     # track of the current one. Note that for the TestBot we don't count or
@@ -785,7 +781,7 @@ if ($TA->GetFile($RptFileName, $FullLogFileName))
   else
   {
     $NewStatus = 'boterror';
-    Error "Unable to open '$FullLogFileName' for reading: $!\n";
+    Error "Unable to open 'log' for reading: $!\n";
     LogTaskError("Unable to open the log file for reading: $!\n");
   }
 }




More information about the wine-cvs mailing list