[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 04/13] Reporting: In report_run_getinfo, abstract code for returning



This will allow us to change the function's API in one place (plus all
the call sites).

No functional change in this patch.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 6c16fdd..2389eb2 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -202,8 +202,14 @@ sub report_run_getinfo ($) {
     #    flight job status
     my ($f) = @_;
     my $status= $f->{status};
+
+    my $single = sub {
+       my ($summary, $colour) = @_;
+       return { Summary => $summary, Colour => $colour };
+    };
+
     if ($status eq 'pass') {
-        return { Summary => "($status)", Colour => $green };
+        return $single->("($status)", $green);
     } elsif ($status eq 'fail' or $status eq 'broken') {
        my $failcolour = $status eq 'fail' ? $red : $yellow;
        our $failstepq //= db_prepare(<<END);
@@ -216,19 +222,18 @@ END
         $failstepq->execute($f->{flight}, $f->{job});
         my $fs= $failstepq->fetchrow_hashref();
         if (!defined $fs) {
-            return { Summary => "(unknown)", Colour => $yellow };
+            return $single->("(unknown)", $yellow);
         } elsif ($fs->{status} eq 'fail') {
-            return { Summary => "$fs->{testid}", Colour => $failcolour };
+            return $single->("$fs->{testid}", $failcolour);
         } elsif ($fs->{status} eq 'broken') {
-            return { Summary => "$fs->{testid} broken", Colour => $yellow };
+            return $single->("$fs->{testid} broken", $yellow);
         } else {
-            return { Summary => "$fs->{testid} $fs->{status}",
-                     Colour => $failcolour };
+            return $single->("$fs->{testid} $fs->{status}", $failcolour);
         }
     } elsif ($status eq 'blocked') {
-        return { Summary => "blocked", Colour => $purple },
+        return $single->("blocked", $purple),
     } else {
-        return { Summary => "($f->{status})", Colour => $yellow };
+        return $single->("($f->{status})", $yellow);
     }
 }
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.