Francois Gouget : testbot: Move log line categorization to LogUtils and simplify line highlighting.
Alexandre Julliard
julliard at winehq.org
Tue Jun 26 09:45:37 CDT 2018
Module: tools
Branch: master
Commit: b53aafbc9281d0b202fa5a7dc0b4682b2f21dfe9
URL: https://source.winehq.org/git/tools.git/?a=commit;h=b53aafbc9281d0b202fa5a7dc0b4682b2f21dfe9
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Jun 26 13:23:25 2018 +0200
testbot: Move log line categorization to LogUtils and simplify line highlighting.
GetLogLineCategory() identifies log lines of interest which makes it
possible to decide how to display them.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 3e40fbc..daa9c0b 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 f05c0f6..07924f4 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);
More information about the wine-cvs
mailing list