[PATCH 2/2] testbot/LogUtils: Keep track of the first line of each error group.

Francois Gouget fgouget at codeweavers.com
Tue Jan 28 05:12:16 CST 2020


This will make it possible to jump to the first line of a test unit that
contains failures.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

This also makes group names fit perfectly into the future log errors 
cache format ;-)

 testbot/lib/WineTestBot/LogUtils.pm | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm
index 75d283381c..4d0d99bfab 100644
--- a/testbot/lib/WineTestBot/LogUtils.pm
+++ b/testbot/lib/WineTestBot/LogUtils.pm
@@ -709,16 +709,20 @@ sub _DumpErrors($$)
   }
 }
 
-sub _AddLogGroup($$)
+sub _AddLogGroup($$;$)
 {
-  my ($LogInfo, $GroupName) = @_;
+  my ($LogInfo, $GroupName, $LineNo) = @_;
 
   # In theory the error group names are all unique. But, just in case, make
   # sure we don't overwrite $LogInfo->{ErrGroups}->{$GroupName}.
   if (!$LogInfo->{ErrGroups}->{$GroupName})
   {
     push @{$LogInfo->{ErrGroupNames}}, $GroupName;
-    $LogInfo->{ErrGroups}->{$GroupName} = { LineNos => [], Errors => [] };
+    $LogInfo->{ErrGroups}->{$GroupName} = {
+      LineNo => $LineNo || 0,
+      LineNos => [],
+      Errors => []
+    };
   }
   return $LogInfo->{ErrGroups}->{$GroupName};
 }
@@ -758,6 +762,10 @@ A hashtable indexed by the error group name. Each entry contains:
 
 =over
 
+=item LineNo
+The line number of the start of this error group. Note that this is normally
+different from the line of the first error in that group.
+
 =item Errors
 An array containing the error messages.
 
@@ -798,7 +806,7 @@ sub GetLogErrors($)
   {
     $LogInfo->{ErrCount} ||= 0;
     my $CurrentModule = "";
-    my $CurrentGroup;
+    my ($CurrentGroup, $GroupLineNo);
     my $LineNo = 0;
     foreach my $Line (<$LogFile>)
     {
@@ -807,6 +815,7 @@ sub GetLogErrors($)
       if ($IsReport and $Line =~ /^([_.a-z0-9-]+):[_a-z0-9]* start /)
       {
         $CurrentModule = $1;
+        $GroupLineNo = $LineNo;
         $CurrentGroup = undef;
         next;
       }
@@ -820,7 +829,7 @@ sub GetLogErrors($)
       }
       if (!$CurrentGroup)
       {
-        $CurrentGroup = _AddLogGroup($LogInfo, $CurrentModule);
+        $CurrentGroup = _AddLogGroup($LogInfo, $CurrentModule, $GroupLineNo || $LineNo);
       }
       _AddLogError($LogInfo, $CurrentGroup, $Line, $LineNo);
     }
@@ -848,7 +857,7 @@ sub GetLogErrors($)
         # Note: $GroupName must not depend on the previous content as this
         #       would break diffs.
         my $GroupName = $IsReport ? "Report errors" : "Task errors";
-        $CurrentGroup = _AddLogGroup($LogInfo, $GroupName);
+        $CurrentGroup = _AddLogGroup($LogInfo, $GroupName, $LineNo);
       }
       _AddLogError($LogInfo, $CurrentGroup, $Line, $LineNo);
     }
-- 
2.20.1



More information about the wine-devel mailing list