[PATCH 2/7] testbot/web: Let LogUtils build the list of task reports and logs.
Francois Gouget
fgouget at codeweavers.com
Tue Jun 26 06:23:46 CDT 2018
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
testbot/lib/WineTestBot/LogUtils.pm | 55 ++++++++++++++++++++++++++++-
testbot/web/JobDetails.pl | 20 ++++-------
2 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm
index daa9c0bd8..3dfd7c5e7 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(GetLogLineCategory ParseTaskLog);
+our @EXPORT = qw(GetLogFileNames GetLogLabel GetLogLineCategory ParseTaskLog);
#
@@ -133,4 +133,57 @@ sub GetLogLineCategory($)
return "none";
}
+=pod
+=over 12
+
+=item C<GetLogFileNames()>
+
+Scans the directory for test reports and task logs and returns their filenames.
+The filenames are returned in the order in which the logs are meant to be
+presented.
+
+=back
+=cut
+
+sub GetLogFileNames($;$)
+{
+ my ($Dir, $IncludeOld) = @_;
+
+ my @Candidates = ("exe32.report", "exe64.report",
+ "log", "err");
+ push @Candidates, "log.old", "err.old" if ($IncludeOld);
+
+ my @Logs;
+ foreach my $FileName (@Candidates)
+ {
+ push @Logs, $FileName if (-f "$Dir/$FileName" and !-z "$Dir/$FileName");
+ }
+ return \@Logs;
+}
+
+my %_LogFileLabels = (
+ "exe32.report" => "32 bit Windows report",
+ "exe64.report" => "64 bit Windows report",
+ "err" => "task errors",
+ "log" => "task log",
+ "err.old" => "old task errors",
+ "log.old" => "old logs",
+);
+
+=pod
+=over 12
+
+=item C<GetLogLabel()>
+
+Returns a user-friendly description of the content of the specified log file.
+
+=back
+=cut
+
+sub GetLogLabel($)
+{
+ my ($LogFileName) = @_;
+ return $_LogFileLabels{$LogFileName};
+}
+
1;
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index 07924f4e6..e5f792929 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -261,14 +261,6 @@ sub GetHtmlLine($$$)
return $Html;
}
-my @MILogFiles = qw(exe32.report exe64.report log log.old);
-my %MILogLabels = (
- "exe32.report" => "32 bit Windows report",
- "exe64.report" => "64 bit Windows report",
- "log" => "task log",
- "log.old" => "old logs",
-);
-
sub InitMoreInfo($)
{
my ($self) = @_;
@@ -282,15 +274,15 @@ sub InitMoreInfo($)
my $Value = $self->GetParam("f$Key");
my $TaskDir = $StepTask->GetTaskDir();
- foreach my $Log (@MILogFiles)
+ foreach my $Log (@{GetLogFileNames($TaskDir, 1)})
{
- if (!-f "$TaskDir/$Log" or -z "$TaskDir/$Log")
+ if ($Log =~ s/^err/log/)
{
- my $Err = $Log;
- next if ($Err !~ s/^log/err/ or !-f "$TaskDir/$Err" or -z "$TaskDir/$Err");
+ # We don't want separate entries for log* and err* but we also want a
+ # log* entry even if only err* exists.
+ next if (($More->{$Key}->{Logs}->[-1] || "") eq $Log);
}
push @{$More->{$Key}->{Logs}}, $Log;
-
$More->{$Key}->{Full} = $Log if (uri_escape($Log) eq $Value);
}
$More->{$Key}->{Full} ||= "";
@@ -385,7 +377,7 @@ sub GenerateBody($)
foreach my $Log (@{$MoreInfo->{Logs}})
{
- $self->GenerateMoreInfoLink($Key, $MILogLabels{$Log}, "Full", $Log);
+ $self->GenerateMoreInfoLink($Key, GetLogLabel($Log), "Full", $Log);
}
print "</div>\n";
--
2.18.0
More information about the wine-devel
mailing list