GetLogLineCategory() identifies log lines of interest which makes it possible to decide how to display them.
Signed-off-by: Francois Gouget fgouget@codeweavers.com ---
This makes it reusable in WineSendLog.pl.
testbot/lib/WineTestBot/LogUtils.pm | 61 +++++++++++++++++++++- testbot/web/JobDetails.pl | 78 +++++++++++------------------ 2 files changed, 88 insertions(+), 51 deletions(-)
diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm index 3e40fbc35..daa9c0bd8 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -27,7 +27,7 @@ WineTestBot::LogUtils - Provides functions to parse task logs
use Exporter 'import'; -our @EXPORT = qw(ParseTaskLog); +our @EXPORT = qw(GetLogLineCategory ParseTaskLog);
# @@ -74,4 +74,63 @@ sub ParseTaskLog($$) return "nolog:Unable to open the task log for reading: $!"; }
+ +# +# Log querying and formatting +# + +=pod +=over 12 + +=item C<GetLogLineCategory()> + +Identifies the category of the given log line: an error message, a todo, just +an informational message or none of these. The category can then be used to +decide whether to hide the line or, on the contrary, highlight it. + +=back +=cut + +sub GetLogLineCategory($) +{ + my ($Line) = @_; + + if ($Line =~ /: Test marked todo: /) + { + return "todo"; + } + if ($Line =~ /: Tests skipped: / or + $Line =~ /^\w+:\w+ skipped /) + { + return "skip"; + } + if ($Line =~ /: Test (?:failed|succeeded inside todo block): / or + $Line =~ /Fatal: test .* does not exist/ or + $Line =~ / done (258)/ or + $Line =~ /: unhandled exception [0-9a-fA-F]{8} at / or + $Line =~ /^Unhandled exception: / or + # Git errors + $Line =~ /^CONFLICT / or + $Line =~ /^error: patch failed:/ or + $Line =~ /^error: corrupt patch / or + # Build errors + $Line =~ /: error: / or + $Line =~ /^Makefile:[0-9]+: recipe for target .* failed$/ or + $Line =~ /^(?:Build|Reconfig|Task): (?!ok)/ or + # Typical perl errors + $Line =~ /^Use of uninitialized value/) + { + return "error"; + } + if ($Line =~ /^+ \S/ or + $Line =~ /^\w+:\w+ start / or + # Build messages + $Line =~ /^(?:Build|Reconfig|Task): ok/) + { + return "info"; + } + + return "none"; +} + 1; diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl index f05c0f62e..07924f4e6 100644 --- a/testbot/web/JobDetails.pl +++ b/testbot/web/JobDetails.pl @@ -28,6 +28,7 @@ use URI::Escape;
use WineTestBot::Config; use WineTestBot::Jobs; +use WineTestBot::LogUtils; use WineTestBot::StepsTasks; use WineTestBot::Engine::Notify;
@@ -228,59 +229,36 @@ sub GeneratePage($) $self->SUPER::GeneratePage(); }
+=pod +=over 12 + +=item C<GetHtmlLine()> + +Determines if the log line should be shown, how, and escapes it so it is valid +HTML. + +When not showing the full log, returns undef except for error messages which +are the only lines tha should be shown. +When showing the full log error messages and other lines of interest are +highlighted to make the log more readable. + +=back +=cut + sub GetHtmlLine($$$) { my ($self, $FullLog, $Line) = @_;
- $Line = $self->escapeHTML($Line); - if ($Line =~ /: Test marked todo: /) - { - return (undef, $Line) if (!$FullLog); - my $Html = $Line; - $Html =~ s~^(.*\S)\s*\r?$~<span class='log-todo'>$1</span>~; - return ($Html, $Line); - } - if ($Line =~ /: Tests skipped: / or - $Line =~ /^\w+:\w+ skipped /) - { - return (undef, $Line) if (!$FullLog); - my $Html = $Line; - $Html =~ s~^(.*\S)\s*\r?$~<span class='log-skip'>$1</span>~; - return ($Html, $Line); - } - if ($Line =~ /: Test (?:failed|succeeded inside todo block): / or - $Line =~ /Fatal: test .* does not exist/ or - $Line =~ / done (258)/ or - $Line =~ /: unhandled exception [0-9a-fA-F]{8} at / or - $Line =~ /^Unhandled exception: / or - # Git errors - $Line =~ /^CONFLICT / or - $Line =~ /^error: patch failed:/ or - $Line =~ /^error: corrupt patch / or - # Build errors - $Line =~ /: error: / or - $Line =~ /^Makefile:[0-9]+: recipe for target .* failed$/ or - $Line =~ /^(?:Build|Reconfig|Task): (?!ok)/ or - # Typical perl errors - $Line =~ /^Use of uninitialized value/) - { - return ($Line, $Line) if (!$FullLog); - my $Html = $Line; - $Html =~ s~^(.*\S)\s*\r?$~<span class='log-error'>$1</span>~; - return ($Html, $Line); - } - if ($FullLog && - ($Line =~ /^+ \S/ or - $Line =~ /^\w+:\w+ start / or - # Build messages - $Line =~ /^(?:Build|Reconfig|Task): ok/)) + my $Category = GetLogLineCategory($Line); + return undef if ($Category ne "error" and !$FullLog); + + my $Html = $self->escapeHTML($Line); + if ($FullLog and $Category ne "none") { - my $Html = $Line; - $Html =~ s~^(.*\S)\s*\r?$~<span class='log-info'>$1</span>~; - return ($Html, $Line); + # Highlight all line categories in the full log + $Html =~ s~^(.*\S)\s*\r?$~<span class='log-$Category'>$1</span>~; } - - return (undef, $Line); + return $Html; }
my @MILogFiles = qw(exe32.report exe64.report log log.old); @@ -429,8 +407,8 @@ sub GenerateBody($) { $CurrentDll = $1; } - my ($Highlight, $Plain) = $self->GetHtmlLine($MoreInfo->{Full}, $Line); - next if (!$MoreInfo->{Full} and !defined $Highlight); + my $Html = $self->GetHtmlLine($MoreInfo->{Full}, $Line); + next if (!defined $Html);
if ($PrintedDll ne $CurrentDll && !$MoreInfo->{Full}) { @@ -451,7 +429,7 @@ sub GenerateBody($) } else { - print(($Highlight || $Plain), "\n"); + print "$Html\n"; } } close($LogFile);