[tools 2/3] testbot/WineSendLog: Use GetSortedItems() to sort the Steps/Tasks.

Francois Gouget fgouget at codeweavers.com
Mon Jun 13 10:20:44 CDT 2022


This avoids having to look up the object in every loop.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/WineSendLog.pl | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/testbot/bin/WineSendLog.pl b/testbot/bin/WineSendLog.pl
index 5affba606..8e2048e23 100755
--- a/testbot/bin/WineSendLog.pl
+++ b/testbot/bin/WineSendLog.pl
@@ -183,7 +183,7 @@ sub SendLog($)
   }
 
   my $StepsTasks = CreateStepsTasks(undef, $Job);
-  my @SortedKeys = sort { $a <=> $b } @{$StepsTasks->GetKeys()};
+  my $SortedStepsTasks = $StepsTasks->GetSortedItems();
 
   my $JobURL = MakeOfficialURL("/JobDetails.pl?Key=". $Job->GetKey());
 
@@ -228,10 +228,8 @@ Content-Disposition: inline
 
 VM                   Status   Failures Command
 EOF
-  foreach my $Key (@SortedKeys)
+  foreach my $StepTask (@$SortedStepsTasks)
   {
-    my $StepTask = $StepsTasks->GetItem($Key);
-
     my $TestFailures = $StepTask->TestFailures;
     $TestFailures = "" if (!defined $TestFailures);
     my $Status = $StepTask->Status;
@@ -248,19 +246,18 @@ EOF
 
   # Print the job summary
   my $JobErrors;
-  foreach my $Key (@SortedKeys)
+  foreach my $StepTask (@$SortedStepsTasks)
   {
-    my $StepTask = $StepsTasks->GetItem($Key);
+    my $Id = $StepTask->Id;
     my $TaskDir = $StepTask->GetTaskDir();
-
     my $LogNames = GetLogFileNames($TaskDir);
-    $JobErrors->{$Key}->{LogNames} = $LogNames;
+    $JobErrors->{$Id}->{LogNames} = $LogNames;
     foreach my $LogName (@$LogNames)
     {
       my $LogInfo = LoadLogErrors("$TaskDir/$LogName");
       next if (!defined $LogInfo->{BadLog} and !$LogInfo->{ErrCount});
-      $JobErrors->{$Key}->{HasErrors} = 1;
-      $JobErrors->{$Key}->{$LogName} = $LogInfo;
+      $JobErrors->{$Id}->{HasErrors} = 1;
+      $JobErrors->{$Id}->{$LogName} = $LogInfo;
 
       print $Sendmail "\n=== ", GetTitle($StepTask, $LogName), " ===\n";
       print $Sendmail "$LogInfo->{BadLog}\n" if (defined $LogInfo->{BadLog});
@@ -275,12 +272,11 @@ EOF
   }
 
   # Print the log attachments
-  foreach my $Key (@SortedKeys)
+  foreach my $StepTask (@$SortedStepsTasks)
   {
-    my $StepTask = $StepsTasks->GetItem($Key);
     my $TaskDir = $StepTask->GetTaskDir();
 
-    foreach my $LogName (@{$JobErrors->{$Key}->{LogNames}})
+    foreach my $LogName (@{$JobErrors->{$StepTask->Id}->{LogNames}})
     {
       print $Sendmail <<"EOF";
 
@@ -325,19 +321,19 @@ EOF
   # However in practice this would only be an issue if the patch reintroduced
   # an error that just disappeared in the latest Wine which is highly unlikely.
   my @Messages;
-  foreach my $Key (@SortedKeys)
+  foreach my $StepTask (@$SortedStepsTasks)
   {
-    next if (!$JobErrors->{$Key}->{HasErrors});
-    my $StepTask = $StepsTasks->GetItem($Key);
+    my $Id = $StepTask->Id;
+    next if (!$JobErrors->{$Id}->{HasErrors});
 
     # Note: We could check $StepTask->Status for TestBot errors. However,
     # whether they are caused by the patch or not, they prevent the TestBot
     # from checking for new errors which justifies sending an email to the
     # mailing list so that the patch receives greater scrutiny.
 
-    foreach my $LogName (@{$JobErrors->{$Key}->{LogNames}})
+    foreach my $LogName (@{$JobErrors->{$Id}->{LogNames}})
     {
-      my $LogInfo = $JobErrors->{$Key}->{$LogName};
+      my $LogInfo = $JobErrors->{$Id}->{$LogName};
       # Skip if there are no errors
       next if (!$LogInfo->{NewCount});
 
@@ -428,12 +424,10 @@ EOF
       DebugTee($Result, "Job-ID: ". $Job->Id ."\n");
       DebugTee($Result, "URL: $JobURL\n");
 
-      foreach my $Key (@SortedKeys)
+      foreach my $StepTask (@$SortedStepsTasks)
       {
-        my $StepTask = $StepsTasks->GetItem($Key);
         my $TaskDir = $StepTask->GetTaskDir();
-
-        foreach my $LogName (@{$JobErrors->{$Key}->{LogNames}})
+        foreach my $LogName (@{$JobErrors->{$StepTask->Id}->{LogNames}})
         {
           print $Result "=== ", GetTitle($StepTask, $LogName), " ===\n";
           DumpLogAndErr($Result, "$TaskDir/$LogName");
-- 
2.30.2




More information about the wine-devel mailing list