From: Francois Gouget Subject: [12/25] testbot/JobDetails: Highlight new errors in the full log too. Message-Id: <8030a8e77269549c4090ebbe2b3927fa2ccce82c.1579000229.git.fgouget@codeweavers.com> Date: Tue, 14 Jan 2020 16:42:15 +0100 (CET) In-Reply-To: References: --- testbot/lib/WineTestBot/LogUtils.pm | 20 +++++++++---- testbot/web/JobDetails.pl | 46 +++++++++++++++++++++++++---- testbot/web/WineTestBot.css | 1 + 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm index 52bf60d93..9dbe6cf0b 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -709,16 +709,17 @@ sub _AddLogGroup($$) if (!$LogInfo->{ErrGroups}->{$GroupName}) { push @{$LogInfo->{ErrGroupNames}}, $GroupName; - $LogInfo->{ErrGroups}->{$GroupName} = { Errors => [] }; + $LogInfo->{ErrGroups}->{$GroupName} = { LineNos => [], Errors => [] }; } return $LogInfo->{ErrGroups}->{$GroupName}; } -sub _AddLogError($$$) +sub _AddLogError($$$;$) { - my ($LogInfo, $ErrGroup, $Line) = @_; + my ($LogInfo, $ErrGroup, $Line, $LineNo) = @_; push @{$ErrGroup->{Errors}}, $Line; + push @{$ErrGroup->{LineNos}}, $LineNo || 0; $LogInfo->{ErrCount}++; } @@ -744,8 +745,13 @@ An array containing the names of all the error groups. A hashtable indexed by the error group name. Each entry contains: =over + =item Errors An array containing the error messages. + +=item LineNos +An array containing the line number of the error in the log file. + =back =back @@ -777,8 +783,10 @@ sub GetLogErrors($) $LogInfo->{ErrCount} ||= 0; my $CurrentModule = ""; my $CurrentGroup; + my $LineNo = 0; foreach my $Line (<$LogFile>) { + $LineNo++; $Line =~ s/\s*$//; if ($IsReport and $Line =~ /^([_.a-z0-9-]+):[_a-z0-9]* start /) { @@ -798,7 +806,7 @@ sub GetLogErrors($) { $CurrentGroup = _AddLogGroup($LogInfo, $CurrentModule); } - _AddLogError($LogInfo, $CurrentGroup, $Line); + _AddLogError($LogInfo, $CurrentGroup, $Line, $LineNo); } close($LogFile); } @@ -813,8 +821,10 @@ sub GetLogErrors($) $LogInfo->{ErrCount} ||= 0; # Add the related extra errors my $CurrentGroup; + my $LineNo = 0; foreach my $Line (<$LogFile>) { + $LineNo++; $Line =~ s/\s*$//; if (!$CurrentGroup) { @@ -823,7 +833,7 @@ sub GetLogErrors($) my $GroupName = $IsReport ? "Report errors" : "Task errors"; $CurrentGroup = _AddLogGroup($LogInfo, $GroupName); } - _AddLogError($LogInfo, $CurrentGroup, $Line); + _AddLogError($LogInfo, $CurrentGroup, $Line, $LineNo); } close($LogFile); } diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl index 48d511ccb..fc18c866f 100644 --- a/testbot/web/JobDetails.pl +++ b/testbot/web/JobDetails.pl @@ -351,19 +351,42 @@ sub GetErrorCategory($) return "error"; } -sub GenerateFullLog($$$;$) +sub GenerateFullLog($$$$;$) { - my ($self, $FileName, $HideLog, $Header) = @_; + my ($self, $FileName, $HideLog, $LogInfo, $Header) = @_; + + my %NewLineNos; + if ($LogInfo and $LogInfo->{NewCount}) + { + foreach my $GroupName (@{$LogInfo->{ErrGroupNames}}) + { + my $Group = $LogInfo->{ErrGroups}->{$GroupName}; + next if (!$Group->{NewCount}); + if (($FileName =~ /\.err$/) == + ($GroupName =~ /^(?:Report errors|Task errors|TestBot errors)$/)) + { + for my $ErrIndex (0..@{$Group->{Errors}} - 1) + { + if ($Group->{IsNew}->[$ErrIndex]) + { + $NewLineNos{$Group->{LineNos}->[$ErrIndex]} = 1; + } + } + } + } + } my $GetCategory = $FileName =~ /\.err$/ ? \&GetErrorCategory : $FileName =~ /\.report$/ ? \&GetReportLineCategory : \&GetLogLineCategory; + my $LineNo = 0; my $IsEmpty = 1; if (open(my $LogFile, "<", $FileName)) { foreach my $Line (<$LogFile>) { + $LineNo++; $Line =~ s/\s*$//; if ($IsEmpty) { @@ -372,8 +395,8 @@ sub GenerateFullLog($$$;$) $IsEmpty = 0; } - my $Category = $GetCategory->($Line); my $Html = $self->escapeHTML($Line); + my $Category = $NewLineNos{$LineNo} ? "fullnew" : $GetCategory->($Line); if ($Category ne "none") { $Html =~ s~^(.*\S)\s*\r?$~$1~; @@ -463,11 +486,24 @@ EOF # Show this log in full, highlighting the important lines # + my $LogInfo; + my $LogFileName = "$TaskDir/$MoreInfo->{Full}"; + if ($MoreInfo->{Full} =~ /\.report$/) + { + $LogInfo = GetLogErrors($LogFileName); + if ($LogInfo->{ErrCount}) + { + # Identify new errors in test reports + my $RefReportPath = $StepTask->GetFullFileName($StepTask->GetRefReportName($MoreInfo->{Full})); + TagNewErrors($RefReportPath, $LogInfo); + } + } + my ($Action, $Url) = $self->GetMoreInfoLink($Key, GetLogLabel($MoreInfo->{Full}), "Full", $MoreInfo->{Full}); $Url = $self->CGI->escapeHTML($Url); my $HideLog = $Action eq "Hide" ? " ondblclick='HideLog(event, \"$Url\")'" : ""; - my $LogIsEmpty = $self->GenerateFullLog("$TaskDir/$MoreInfo->{Full}", $HideLog); + my $LogIsEmpty = $self->GenerateFullLog($LogFileName, $HideLog, $LogInfo); my $EmptyDiag; if ($LogIsEmpty) { @@ -490,7 +526,7 @@ EOF my $ErrHeader = $MoreInfo->{Full} =~ /\.report/ ? "report" : "task"; $ErrHeader = "old $ErrHeader" if ($MoreInfo->{Full} =~ /^old_/); $ErrHeader = "
". ucfirst($ErrHeader) ." errors
"; - my $ErrIsEmpty = $self->GenerateFullLog("$TaskDir/$MoreInfo->{Full}.err", $HideLog, $ErrHeader); + my $ErrIsEmpty = $self->GenerateFullLog("$LogFileName.err", $HideLog, $LogInfo, $ErrHeader); print $EmptyDiag if ($ErrIsEmpty and defined $EmptyDiag); } else diff --git a/testbot/web/WineTestBot.css b/testbot/web/WineTestBot.css index f58835583..9a23f5fa8 100644 --- a/testbot/web/WineTestBot.css +++ b/testbot/web/WineTestBot.css @@ -402,6 +402,7 @@ pre .log-boterror { color: #cc0052; } .log-diag { color: #e56300; } .log-new { color: #e56e00; font-weight: bold; } +.log-fullnew { color: red; font-weight: bold; } a.title { color:inherit; text-decoration: none; } -- 2.20.1