Francois Gouget : testbot/web: Let LogUtils build the list of task reports and logs.

Alexandre Julliard julliard at winehq.org
Tue Jun 26 09:45:37 CDT 2018


Module: tools
Branch: master
Commit: 6e4ee08776b7aea8cac264487d6976cd6cc21501
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=6e4ee08776b7aea8cac264487d6976cd6cc21501

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Jun 26 13:23:46 2018 +0200

testbot/web: Let LogUtils build the list of task reports and logs.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 daa9c0b..3dfd7c5 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 07924f4..e5f7929 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";
 




More information about the wine-cvs mailing list