Cope with negative failure numbers.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 12 Dec 2010 22:22:28 +0000 (23:22 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 12 Dec 2010 22:22:28 +0000 (23:22 +0100)
buildfarm/build.py
buildfarm/tests/test_build.py

index b6602ab..7c371b1 100644 (file)
@@ -125,6 +125,7 @@ class BuildStatus(object):
             return False
         if ("panic" in self.other_failures and
             not "panic" in older.other_failures):
+            # If this build introduced panics, then that's always worse.
             return True
         if len(self.stages) < len(older.stages):
             # Less stages completed
@@ -132,8 +133,14 @@ class BuildStatus(object):
         for ((old_name, old_result), (new_name, new_result)) in zip(
             older.stages, self.stages):
             assert old_name == new_name
-            if new_result > old_result:
+            if new_result == old_result:
+                continue
+            if new_result < 0 and old_result >= 0:
                 return True
+            elif new_result >= 0 and old_result < 0:
+                return False
+            else:
+                return (abs(new_result) > abs(old_result))
         return False
 
     def __cmp__(self, other):
index 6facb79..2fa31c1 100755 (executable)
@@ -341,6 +341,20 @@ class BuildStatusRegressedSinceTests(testtools.TestCase):
         b = BuildStatus(stages2, set(other_failures2))
         self.assertEquals(expected, b.regressed_since(a))
 
+    def test_negative(self):
+        self.assertRegressedSince(
+            False,
+            ([("CONFIGURE", -1)], []),
+            ([("CONFIGURE", 2)], []))
+        self.assertRegressedSince(
+            False,
+            ([("CONFIGURE", -1)], []),
+            ([("CONFIGURE", 0)], []))
+        self.assertRegressedSince(
+            True,
+            ([("CONFIGURE", -1)], []),
+            ([("CONFIGURE", -3)], []))
+
     def test_same(self):
         self.assertRegressedSince(
             False,