Also standardize on $LogPath for the full path to log files, and $LogName for their basename, which matches the field names.
Signed-off-by: Francois Gouget fgouget@codeweavers.com ---
This patch is still about improving the Parse*() and GetLogError() APIs: the new fields are not used yet but will be in following patches.
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 9aa2e81c70..8187826e34 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>) { @@ -757,10 +766,10 @@ An array containing the error messages.
sub GetLogErrors($) { - my ($LogFileName) = @_; + my ($LogPath) = @_;
my ($IsReport, $GetCategory); - if ($LogFileName =~ /.report$/) + if ($LogPath =~ /.report$/) { $IsReport = 1; $GetCategory = &GetReportLineCategory; @@ -770,12 +779,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 = ""; @@ -805,14 +818,14 @@ sub GetLogErrors($) } close($LogFile); } - elsif (-f $LogFileName) + elsif (-f $LogPath) { - $LogInfo->{BadLog} = "Could not open '". basename($LogFileName) ."' for reading: $!"; + $LogInfo->{BadLog} = "Could not open '$LogName' for reading: $!"; my $Group = _AddLogGroup($LogInfo, "TestBot errors"); _AddLogError($LogInfo, $Group, $LogInfo->{BadLog}); }
- if (open(my $LogFile, "<", "$LogFileName.err")) + if (open(my $LogFile, "<", "$LogPath.err")) { $LogInfo->{ErrCount} ||= 0; # Add the related extra errors @@ -831,9 +844,9 @@ sub GetLogErrors($) } close($LogFile); } - elsif (-f "$LogFileName.err") + elsif (-f "$LogPath.err") { - $LogInfo->{BadLog} ||= "Could not open '". basename($LogFileName) .".err' for reading: $!"; + $LogInfo->{BadLog} ||= "Could not open '$LogName.err' for reading: $!"; my $Group = _AddLogGroup($LogInfo, "TestBot errors"); _AddLogError($LogInfo, $Group, $LogInfo->{BadLog}); }