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

Jelmer Vernooij jelmer at samba.org
Wed Nov 17 01:57:49 MST 2010


The branch, master has been updated
       via  49380c5 Add tests for regressed_since.
      from  2f13a56 Merge tests.

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


- Log -----------------------------------------------------------------
commit 49380c57cc9f0bb42aed43d8ef2be1464259ba26
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 17 09:56:58 2010 +0100

    Add tests for regressed_since.

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

Summary of changes:
 buildfarm/data.py            |   16 ++++++++++++----
 buildfarm/tests/test_data.py |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildfarm/data.py b/buildfarm/data.py
index 5c7fe7f..ffdb9e5 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -87,17 +87,25 @@ class BuildStatus(object):
     def _status_tuple(self):
         return [sr.result for sr in self.stages]
 
-    def regressed_since(self, other):
+    def regressed_since(self, older):
         """Check if this build has regressed since another build."""
         if "disk full" in self.other_failures:
             return False
-        if "timeout" in self.other_failures and "timeout" in other.other_failures:
+        if "timeout" in self.other_failures and "timeout" in older.other_failures:
             # When the timeout happens exactly can differ slightly, so it's okay
             # if the numbers are a bit different..
             return False
-        if "panic" in self.other_failures and not "panic" in other.other_failures:
+        if "panic" in self.other_failures and not "panic" in older.other_failures:
             return True
-        return cmp(self._status_tuple(), other._status_tuple())
+        if len(self.stages) < len(older.stages):
+            # Less stages completed
+            return True
+        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:
+                return True
+        return False
 
     def __cmp__(self, other):
         other_extra = other.other_failures - self.other_failures
diff --git a/buildfarm/tests/test_data.py b/buildfarm/tests/test_data.py
index c8d50f4..4e17611 100755
--- a/buildfarm/tests/test_data.py
+++ b/buildfarm/tests/test_data.py
@@ -307,6 +307,42 @@ class BuildStatusTest(testtools.TestCase):
         self.assertEquals(cmp(d, e), -1)
 
 
+class BuildStatusRegressedSinceTests(testtools.TestCase):
+
+    def assertRegressedSince(self, expected, old_status, new_status):
+        (stages1, other_failures1) = old_status
+        (stages2, other_failures2) = new_status
+        a = data.BuildStatus(
+            [data.BuildStageResult(n, r) for (n, r) in stages1], set(other_failures1))
+        b = data.BuildStatus(
+            [data.BuildStageResult(n, r) for (n, r) in stages2], set(other_failures2))
+        self.assertEquals(expected, b.regressed_since(a))
+
+    def test_same(self):
+        self.assertRegressedSince(
+            False,
+            ([("CONFIGURE", 2)], []),
+            ([("CONFIGURE", 2)], []))
+
+    def test_same_panic(self):
+        self.assertRegressedSince(
+            False,
+            ([("CONFIGURE", 2)], ["panic"]),
+            ([("CONFIGURE", 2)], ["panic"]))
+
+    def test_other_failures_gone(self):
+        self.assertRegressedSince(
+            True,
+            ([("CONFIGURE", 0)], ["panic"]),
+            ([("CONFIGURE", 2)], ["panic"]))
+
+    def test_more_stages_completed(self):
+        self.assertRegressedSince(
+            False,
+            ([("CONFIGURE", 0)], []),
+            ([("CONFIGURE", 0), ("BUILD", 0)], []))
+
+
 class UploadBuildResultStoreTestBase(object):
 
     def test_build_fname(self):


-- 
build.samba.org


More information about the samba-cvs mailing list