Francois Gouget : testbot/web: Improve the job status reporting on the home page.

Alexandre Julliard julliard at winehq.org
Tue Jan 22 12:57:44 CST 2013


Module: tools
Branch: master
Commit: 9250db91d194c341aac98a676df235e2c3533443
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=9250db91d194c341aac98a676df235e2c3533443

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Jan 22 04:11:34 2013 +0100

testbot/web: Improve the job status reporting on the home page.

It is interesting to know if there were test failures even if a VM
misbehaved. So report test failures even if some of the job's tasks
failed.  Conversely, don't claim that jobs like the 'Wine update' have
0 test failures.  Colorize the status to make errors and test failures
easier to spot.  Also link to the job details page from the status
field.

---

 testbot/web/WineTestBot.css |    6 ++++
 testbot/web/index.pl        |   64 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/testbot/web/WineTestBot.css b/testbot/web/WineTestBot.css
index 29902ff..b7e7248 100644
--- a/testbot/web/WineTestBot.css
+++ b/testbot/web/WineTestBot.css
@@ -320,3 +320,9 @@ pre
    margin-bottom: 2em;
    background-color: red;
 }
+
+.queued    { color: black; }
+.running   { color: blue; }
+.success   { color: green; }
+.testfail  { color: red; }
+.botfail   { color: #e55600; }
diff --git a/testbot/web/index.pl b/testbot/web/index.pl
index 20ac591..6d88106 100644
--- a/testbot/web/index.pl
+++ b/testbot/web/index.pl
@@ -20,6 +20,7 @@ use strict;
 
 package JobStatusBlock;
 
+use URI::Escape;
 use ObjectModel::CGI::CollectionBlock;
 use WineTestBot::Branches;
 
@@ -76,23 +77,64 @@ sub GetDisplayValue
     return $Item->Patch->FromName;
   }
 
-  if ($PropertyDescriptor->GetName() eq "Status" &&
-      $Item->Status eq "completed")
+  return $self->SUPER::GetDisplayValue(@_);
+}
+
+sub GenerateDataCell
+{
+  my $self = shift;
+  my ($Item, $PropertyDescriptor, $DetailsPage) = @_;
+
+  my $PropertyName = $PropertyDescriptor->GetName();
+  if ($PropertyName eq "Status")
   {
-    my $Failures = 0;
-    my $Steps = $Item->Steps;
-    foreach my $StepKey (@{$Steps->GetKeys()})
+    print "<td><a href='/JobDetails.pl?Key=", uri_escape($Item->GetKey()), "'>";
+
+    my %HTMLChunks = ("queued" => "<span class='queued'>queued</span>",
+                      "running" => "<span class='running'>running</span>",
+                      "completed" => "<span class='success'>completed</span>",
+                      "failed" => "<span class='botfail'>failed</span>");
+    my $Status = $Item->Status;
+    my $HTMLStatus = $HTMLChunks{$Status} || $Status;
+    if ($Status eq "completed" || $Status eq "failed")
     {
-      my $Tasks = $Steps->GetItem($StepKey)->Tasks;
-      foreach my $TaskKey (@{$Tasks->GetKeys()})
+      my $Failures = 0;
+      my $HasTestResult;
+      my $Steps = $Item->Steps;
+      foreach my $StepKey (@{$Steps->GetKeys()})
+      {
+        my $Tasks = $Steps->GetItem($StepKey)->Tasks;
+        foreach my $TaskKey (@{$Tasks->GetKeys()})
+        {
+          my $TaskFailures = $Tasks->GetItem($TaskKey)->TestFailures;
+          if ($TaskFailures ne "")
+          {
+            $HasTestResult = 1;
+            $Failures += $TaskFailures;
+          }
+        }
+      }
+      if (!$HasTestResult)
       {
-        $Failures += $Tasks->GetItem($TaskKey)->TestFailures;
+        print $HTMLStatus;
+      }
+      else
+      {
+        $HTMLStatus = $Item->Status eq "completed" ? "" : "$HTMLStatus - ";
+        my $class = $Failures ? "testfail" : "success";
+        print "$HTMLStatus<span class='$class'>$Failures test failures</span>";
       }
     }
-    return $Item->Status . " - " . $Failures . " failures";
+    else
+    {
+      print $HTMLStatus;
+    }
+    print "</a></td>\n";
+  }
+  else
+  {
+    $self->SUPER::GenerateDataCell(@_);
   }
-
-  return $self->SUPER::GetDisplayValue(@_);
 }
 
 package VMStatusBlock;




More information about the wine-cvs mailing list