[SCM] build.samba.org - branch master updated

Matthieu Patou mat at samba.org
Tue Nov 9 14:10:27 MST 2010


The branch, master has been updated
       via  2753253 add unit tests
       via  eafd9ba Move compare function to BuildStatus class
       via  93b3c8c rewrite the sort status function
      from  0ddfedc Improve status for special cases

http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2753253ee5e4f48d1f648cee00ae3da7b73e95b9
Author: Matthieu Patou <mat at matws.net>
Date:   Wed Nov 10 00:09:13 2010 +0300

    add unit tests

commit eafd9baee7c6eb3cf2dca5062e5897d9e875f07b
Author: Matthieu Patou <mat at matws.net>
Date:   Wed Nov 10 00:09:03 2010 +0300

    Move compare function to BuildStatus class

commit 93b3c8ce5bcd7cc529974543d4ffb93e224b9301
Author: Matthieu Patou <mat at matws.net>
Date:   Tue Nov 9 22:15:40 2010 +0300

    rewrite the sort status function

-----------------------------------------------------------------------

Summary of changes:
 buildfarm/data.py            |   23 +++++++++++++++++++++++
 buildfarm/tests/test_data.py |   42 ++++++++++++++++++++++++++++++++++++++++++
 web/build.py                 |   29 +++--------------------------
 3 files changed, 68 insertions(+), 26 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildfarm/data.py b/buildfarm/data.py
index a637c3c..ffe4d64 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -57,6 +57,29 @@ class BuildStatus(object):
             return False
         return cmp(self._status_tuple(), other._status_tuple())
 
+    def cmp(a, b):
+
+        #Give more importance to other failures
+        if len(b.other_failures):
+            return 1
+        if len(a.other_failures):
+            return -1
+
+        la = len(a.stages)
+        lb = len(b.stages)
+        if la > lb:
+            return 1
+        elif lb > la:
+            return -1
+        else:
+            if la == 0:
+                return 0
+
+            sa = a.stages[-1]
+            sb = b.stages[-1]
+
+            return cmp(sb[1], sa[1])
+
     def __str__(self):
         return repr((self.stages, self.other_failures))
 
diff --git a/buildfarm/tests/test_data.py b/buildfarm/tests/test_data.py
index 66e4f06..aff868a 100755
--- a/buildfarm/tests/test_data.py
+++ b/buildfarm/tests/test_data.py
@@ -250,3 +250,45 @@ CC_CHECKER STATUS:	2
         self.assertEquals(res.stages,
             [("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 2)])
 
+
+class BuildStatusTest(testtools.TestCase):
+
+    def test_cmp_equal(self):
+        a = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 2)])
+        b = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 2)])
+
+        self.assertEquals(a.cmp(b), 0)
+
+        self.assertEquals(data.BuildStatus().cmp(data.BuildStatus()), 0)
+
+    def test_cmp_bigger(self):
+        a = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 3)])
+        b = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 2)])
+        c = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3)])
+        d = data.BuildStatus([], ("super error"))
+        e = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 1)], ("super error"))
+
+        # less stage means smaller, more error/higher error code means smaller as well
+        self.assertEquals(b.cmp(a), 1)
+
+        self.assertEquals(a.cmp(c), 1)
+
+        self.assertEquals(a.cmp(d), 1)
+
+        self.assertEquals(b.cmp(e), 1)
+
+    def test_cmp_smaller(self):
+        a = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 2)])
+        b = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 1)])
+        c = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3)])
+        d = data.BuildStatus([], ("super error"))
+        e = data.BuildStatus([("CONFIGURE", 2), ("TEST", 3), ("CC_CHECKER", 1)], ("super error"))
+
+        # less stage means smaller, more error/higher error code means smaller as well
+        self.assertEquals(a.cmp(b), -1)
+
+        self.assertEquals(c.cmp(b), -1)
+
+        self.assertEquals(d.cmp(c), -1)
+
+        self.assertEquals(e.cmp(c), -1)
diff --git a/web/build.py b/web/build.py
index 5b2a605..a4bed10 100755
--- a/web/build.py
+++ b/web/build.py
@@ -257,36 +257,13 @@ def view_recent_builds(myself, tree, sort_by):
     last_host = ""
     all_builds = []
 
-    def status_cmp(a, b):
-        bstat = build_status_vals(b)
-        astat = build_status_vals(a)
-
-        # handle panic
-        if len(bstat) > 5 and bstat[5]:
-            return 1
-        elif len(astat) > 5 and astat[5]:
-            return -1
-
-        # If we have ok/ok/ok/ok/- or ok/ok/ok/ok/ok then we want the line to be at the end
-        if len(bstat) == 5:
-            if bstat[0] == bstat[1] == bstat[2] == bstat[3] == "0":
-                return -1
-        if len(astat) == 5:
-            if astat[0] == astat[1] == astat[2] == astat[3] == "0":
-                return 1
-
-        # Give more weight to higher stage (ie. install error before test errors)
-        return (cmp((10000 * astat[3] + 1000*astat[2] + 100 * astat[1] + astat[0]),
-                    (10000 * bstat[3] + 1000*bstat[2] + 100 * bstat[1] + bstat[0])))
-
-
     cmp_funcs = {
         "revision": lambda a, b: cmp(a[7], b[7]),
         "age": lambda a, b: cmp(a[0], b[0]),
         "host": lambda a, b: cmp(a[2], b[2]),
         "platform": lambda a, b: cmp(a[1], b[1]),
         "compiler": lambda a, b: cmp(a[3], b[3]),
-        "status": lambda a, b: status_cmp(a[5], b[5]),
+        "status": lambda a, b: a[6].cmp(b[6]),
         }
 
     assert tree in trees, "not a build tree"
@@ -314,7 +291,7 @@ def view_recent_builds(myself, tree, sort_by):
                                             % (myself, host.name.encode("utf-8"),
                                                tree, compiler, host.name.encode("utf-8"),
                                                host.name.encode("utf-8")),
-                                        compiler, tree, status,
+                                        compiler, tree, status, build.status(),
                                         revision_link(myself, revision, tree),
                                         revision_time])
 
@@ -339,7 +316,7 @@ def view_recent_builds(myself, tree, sort_by):
     for build in all_builds:
         yield "<tr>"
         yield "<td>%s</td>" % util.dhm_time(build[0])
-        yield "<td>%s</td>" % build[6]
+        yield "<td>%s</td>" % build[7]
         yield "<td>%s</td>" % build[4]
         yield "<td>%s</td>" % build[1]
         yield "<td>%s</td>" % build[2]


-- 
build.samba.org


More information about the samba-cvs mailing list