From: Francois Gouget Subject: [14/25] testbot/LogUtils: Store the filename in the $LogInfo structures. Message-Id: <0f185bdafbdf2d5830a272dd000307ddfd9cef67.1579000229.git.fgouget@codeweavers.com> Date: Tue, 14 Jan 2020 16:42:24 +0100 (CET) In-Reply-To: References: --- testbot/lib/WineTestBot/LogUtils.pm | 55 ++++++++++++++++++----------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm index 3fcb9ac41..3e93c95c7 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -90,16 +90,22 @@ Contains an error message if the task log could not be read. sub ParseTaskLog($) { - my ($FileName) = @_; + my ($LogPath) = @_; + + my $LogName = basename($LogPath); + my $LogInfo = { + LogName => $LogName, + LogPath => $LogPath, + }; my $LogFile; - if (!open($LogFile, "<", $FileName)) + if (!open($LogFile, "<", $LogPath)) { - my $LogName = basename($FileName); - return {BadLog => "Unable to open '$LogName' for reading: $!"}; + $LogInfo->{BadLog} = "Unable to open '$LogName' for reading: $!"; + return $LogInfo; } - my $LogInfo = {Type => "build"}; + $LogInfo->{Type} = "build"; foreach my $Line (<$LogFile>) { chomp $Line; @@ -362,16 +368,12 @@ Contains an error message if the report could not be read. sub ParseWineTestReport($$$) { - my ($FileName, $IsWineTest, $TaskTimedOut) = @_; - - my $LogFile; - if (!open($LogFile, "<", $FileName)) - { - my $LogName = basename($FileName); - return {BadLog => "Unable to open '$LogName' for reading: $!"}; - } + my ($LogPath, $IsWineTest, $TaskTimedOut) = @_; + my $LogName = basename($LogPath); my $LogInfo = { + LogName => $LogName, + LogPath => $LogPath, IsWineTest => $IsWineTest, TaskTimedOut => $TaskTimedOut, @@ -381,6 +383,13 @@ sub ParseWineTestReport($$$) Extra => [], }; + my $LogFile; + if (!open($LogFile, "<", $LogPath)) + { + $LogInfo->{BadLog} = "Unable to open '$LogName' for reading: $!"; + return $LogInfo; + } + my $Cur = _NewCurrentUnit("", ""); foreach my $Line (<$LogFile>) { @@ -768,10 +777,10 @@ An array containing the line number of the error in the log file. sub GetLogErrors($) { - my ($LogFileName) = @_; + my ($LogPath) = @_; my ($IsReport, $GetCategory); - if ($LogFileName =~ /\.report$/) + if ($LogPath =~ /\.report$/) { $IsReport = 1; $GetCategory = \&GetReportLineCategory; @@ -781,12 +790,16 @@ sub GetLogErrors($) $GetCategory = \&GetLogLineCategory; } + my $LogName = basename($LogPath); my $LogInfo = { + LogName => $LogName, + LogPath => $LogPath, + ErrCount => undef, # until we open a log ErrGroupNames => [], ErrGroups => {}, }; - if (open(my $LogFile, "<", $LogFileName)) + if (open(my $LogFile, "<", $LogPath)) { $LogInfo->{ErrCount} ||= 0; my ($CurrentModule, $ModuleLineNo) = ("", 0); @@ -819,13 +832,13 @@ sub GetLogErrors($) } close($LogFile); } - elsif (-f $LogFileName) + elsif (-f $LogPath) { my $Group = _AddLogGroup($LogInfo, "TestBot errors"); - _AddLogError($LogInfo, $Group, "Could not open '". basename($LogFileName) ."' for reading: $!"); + _AddLogError($LogInfo, $Group, "Could not open '$LogName' for reading: $!"); } - if (open(my $LogFile, "<", "$LogFileName.err")) + if (open(my $LogFile, "<", "$LogPath.err")) { $LogInfo->{ErrCount} ||= 0; # Add the related extra errors @@ -846,10 +859,10 @@ sub GetLogErrors($) } close($LogFile); } - elsif (-f "$LogFileName.err") + elsif (-f "$LogPath.err") { my $Group = _AddLogGroup($LogInfo, "TestBot errors"); - _AddLogError($LogInfo, $Group, "Could not open '". basename($LogFileName) .".err' for reading: $!"); + _AddLogError($LogInfo, $Group, "Could not open '$LogName.err' for reading: $!"); } return $LogInfo; -- 2.20.1