_SaveLogErrors() provides more details about the errors than the old _DumpErrors() code did.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/WineTestBot/LogUtils.pm | 90 +++++++++++++---------------- 1 file changed, 39 insertions(+), 51 deletions(-)
diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm index 2128c97986..2104ffa0e0 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -696,24 +696,6 @@ sub GetLogLabel($) return defined $Label ? sprintf($Label, $Extra) : $LogFileName; }
- -sub _DumpErrors($$) -{ - my ($Label, $LogInfo) = @_; - - print STDERR "$Label: ", join(" ", keys %$LogInfo), "\n"; - my $GroupNames = $LogInfo->{ErrGroupNames}; - print STDERR " Groups=", scalar(@$GroupNames), " [", join(",", @$GroupNames), "]\n"; - my @ErrorKeys = sort keys %{$LogInfo->{Groups}}; - print STDERR " Errors=", scalar(@ErrorKeys), " [", join(",", @ErrorKeys), "]\n"; - foreach my $GroupName (@$GroupNames) - { - print STDERR " [$GroupName]\n"; - my $Group = $LogInfo->{Groups}->{$GroupName}; - print STDERR " [$_]\n" for (@{$Group->{Errors}}); - } -} - sub _AddLogGroup($$;$) { my ($LogInfo, $GroupName, $LineNo) = @_; @@ -868,21 +850,7 @@ sub GetLogErrors($)
Loads the specified log errors file.
-The file contains two types of lines: -* GroupName lines - <GroupName> - Where <GroupName> is a unique string which would typically be the name of a - WineTest dll or program, but may also be empty or be used to specify an - extra group errors. It must not start with a space. - -* Error lines - <Space> <New> <SrcLineNo> <Error> - Where: - - <Space> is a space, as well as the spaces in the line above. - - <New> is either 'n' for new errors, or 'o' for old ones. - - <SrcLineNo> is the 1-base line number of the error in the source log file. - If there is no source line then this should be 0. - - <Error> is the error message. +See _WriteLogErrors() for the format of the errors file.
Returns the errors in the same format as TagNewErrors().
@@ -958,11 +926,11 @@ sub LoadLogErrors($) =pod =over 12
-=item C<_SaveLogErrors()> +=item C<_WriteLogErrors()>
-Saves the LogInfo structure to <LogName>.errors. +Writes the LogInfo structure in text form to the specified file descriptor.
-The file contains lines of the form: +All lines follow are of the following form: <type> <value1> <value2>
The values depend on the <type> of the line. <type> and <value1> must not @@ -993,6 +961,27 @@ different type. =back =cut
+sub _WriteLogErrors($$) +{ + my ($Fh, $LogInfo) = @_; + + foreach my $Name ("BadRef", "NoRef") + { + next if (!defined $LogInfo->{$Name}); + print $Fh "p $Name $LogInfo->{$Name}\n"; + } + foreach my $GroupName (@{$LogInfo->{ErrGroupNames}}) + { + my $Group = $LogInfo->{ErrGroups}->{$GroupName}; + print $Fh "g $Group->{LineNo} $GroupName\n"; + foreach my $Index (0..@{$Group->{Errors}} - 1) + { + my $IsNew = $Group->{IsNew}->[$Index] ? "n" : "o"; + print $Fh "$IsNew $Group->{LineNos}->[$Index] $Group->{Errors}->[$Index]\n"; + } + } +} + sub _SaveLogErrors($) { my ($LogInfo) = @_; @@ -1000,21 +989,7 @@ sub _SaveLogErrors($) my $ErrorsPath = "$LogInfo->{LogPath}.errors"; if (open(my $ErrorsFile, ">", $ErrorsPath)) { - foreach my $Name ("BadRef", "NoRef") - { - next if (!defined $LogInfo->{$Name}); - print $ErrorsFile "p $Name $LogInfo->{$Name}\n"; - } - foreach my $GroupName (@{$LogInfo->{ErrGroupNames}}) - { - my $Group = $LogInfo->{ErrGroups}->{$GroupName}; - print $ErrorsFile "g $Group->{LineNo} $GroupName\n"; - foreach my $Index (0..@{$Group->{Errors}} - 1) - { - my $IsNew = $Group->{IsNew}->[$Index] ? "n" : "o"; - print $ErrorsFile "$IsNew $Group->{LineNos}->[$Index] $Group->{Errors}->[$Index]\n"; - } - } + _WriteLogErrors($ErrorsFile, $LogInfo); close($ErrorsFile);
# Set the mtime so Janitor reaps both at the same time @@ -1024,6 +999,19 @@ sub _SaveLogErrors($) return "Could not open '$LogInfo->{LogName}.errors' for writing: $!"; }
+sub _DumpErrors($$) +{ + my ($Label, $LogInfo) = @_; + + print STDERR "$Label:\n"; + foreach my $Key (sort keys %{$LogInfo}) + { + next if ($Key =~ /^(?:ErrGroupNames|ErrGroups|NewCount)$/); + print STDERR "+ $Key $LogInfo->{$Key}\n"; + } + _WriteLogErrors(*STDERR, $LogInfo); +} +
# # New error detection