From: Francois Gouget Subject: [13/25] testbot/LogUtils: Keep track of the first line of each error group. Message-Id: <6d974dc92e9e2530434763346cc7ffe6a076c621.1579000229.git.fgouget@codeweavers.com> Date: Tue, 14 Jan 2020 16:42:20 +0100 (CET) In-Reply-To: References: This will make it possible to jump to the first line of a test unit that contains failures. --- 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 9dbe6cf0b..3fcb9ac41 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -700,16 +700,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}; } @@ -746,6 +750,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. @@ -781,7 +789,7 @@ sub GetLogErrors($) if (open(my $LogFile, "<", $LogFileName)) { $LogInfo->{ErrCount} ||= 0; - my $CurrentModule = ""; + my ($CurrentModule, $ModuleLineNo) = ("", 0); my $CurrentGroup; my $LineNo = 0; foreach my $Line (<$LogFile>) @@ -790,6 +798,7 @@ sub GetLogErrors($) $Line =~ s/\s*$//; if ($IsReport and $Line =~ /^([_.a-z0-9-]+):[_a-z0-9]* start /) { + $ModuleLineNo = $LineNo; $CurrentModule = $1; $CurrentGroup = undef; next; @@ -804,7 +813,7 @@ sub GetLogErrors($) } if (!$CurrentGroup) { - $CurrentGroup = _AddLogGroup($LogInfo, $CurrentModule); + $CurrentGroup = _AddLogGroup($LogInfo, $CurrentModule, $ModuleLineNo); } _AddLogError($LogInfo, $CurrentGroup, $Line, $LineNo); } @@ -831,7 +840,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