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

Jelmer Vernooij jelmer at samba.org
Thu Nov 11 14:55:34 MST 2010


The branch, master has been updated
       via  3de05b3 Add some more base buildfarm tests.
       via  23a0e49 Fix caching buildfarm.
       via  324bb02 make import-and-analyse executable.
      from  46d2d55 Reintroduce readonly parameter, remove unnecessary code.

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


- Log -----------------------------------------------------------------
commit 3de05b3e869488cf6d8eb395a3086377254e3c35
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Thu Nov 11 22:56:15 2010 +0100

    Add some more base buildfarm tests.

commit 23a0e4992b633a6e44c0dcfdf24702e2456b4e4a
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Thu Nov 11 22:41:46 2010 +0100

    Fix caching buildfarm.

commit 324bb026c566f8ea0e796adaccf584e7bb8e7d23
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Thu Nov 11 22:38:35 2010 +0100

    make import-and-analyse executable.

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

Summary of changes:
 buildfarm/__init__.py             |   21 ++++----
 buildfarm/tests/__init__.py       |   63 ------------------------
 buildfarm/tests/test_buildfarm.py |   95 +++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+), 73 deletions(-)
 create mode 100644 buildfarm/tests/test_buildfarm.py
 mode change 100644 => 100755 import-and-analyse.py


Changeset truncated at 500 lines:

diff --git a/buildfarm/__init__.py b/buildfarm/__init__.py
index ea5ecbd..fdb197c 100644
--- a/buildfarm/__init__.py
+++ b/buildfarm/__init__.py
@@ -49,6 +49,7 @@ def read_trees_from_conf(path):
 
 
 def lcov_extract_percentage(text):
+    """Extract the coverage percentage from the lcov file."""
     m = re.search('\<td class="headerItem".*?\>Code\&nbsp\;covered\:\<\/td\>.*?\n.*?\<td class="headerValue".*?\>([0-9.]+) \%', text)
     if m:
         return m.group(1)
@@ -102,7 +103,7 @@ class BuildFarm(object):
         file = os.path.join(self.lcovdir, self.LCOVHOST, tree, "index.html")
         try:
             lcov_html = util.FileLoad(file)
-        except OSError:
+        except (OSError, IOError):
             # File does not exist
             raise data.NoSuchBuildError(tree, self.LCOVHOST, "lcov")
 
@@ -136,30 +137,30 @@ class BuildFarm(object):
 class CachingBuildFarm(BuildFarm):
 
     def __init__(self, path=None, readonly=False, cachedirname=None):
+        self._cachedirname = cachedirname
+        self.readonly = readonly
         super(CachingBuildFarm, self).__init__(path)
 
-        if cachedirname:
-            self.cachedir = os.path.join(self.path, cachedirname)
+    def _get_cachedir(self):
+        if self._cachedirname is not None:
+            return os.path.join(self.path, self._cachedirname)
         else:
-            self.cachedir = os.path.join(self.path, "cache")
-        self.builds = self._open_build_results()
-        self.upload_builds = self._open_upload_build_results()
-        self.readonly = readonly
+            return os.path.join(self.path, "cache")
 
     def _open_build_results(self):
         from buildfarm import data
         return data.CachingBuildResultStore(os.path.join(self.path, "data", "oldrevs"),
-                self.cachedir, reaodnly=self.readonly)
+                self._get_cachedir(), readonly=self.readonly)
 
     def _open_upload_build_results(self):
         from buildfarm import data
         return data.CachingUploadBuildResultStore(os.path.join(self.path, "data", "upload"),
-                self.cachedir, readonly=self.readonly)
+                self._get_cachedir(), readonly=self.readonly)
 
     def lcov_status(self, tree):
         """get status of build"""
         from buildfarm import data, util
-        cachefile = os.path.join(self.cachedir,
+        cachefile = os.path.join(self._get_cachedir(),
                                     "lcov.%s.%s.status" % (self.LCOVHOST, tree))
         file = os.path.join(self.lcovdir, self.LCOVHOST, tree, "index.html")
         try:
diff --git a/buildfarm/tests/__init__.py b/buildfarm/tests/__init__.py
index c414bb1..65912f8 100644
--- a/buildfarm/tests/__init__.py
+++ b/buildfarm/tests/__init__.py
@@ -15,13 +15,10 @@
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-from buildfarm import BuildFarm
-
 import os
 from testtools import TestCase
 import shutil
 import tempfile
-import testtools
 
 
 class BuildFarmTestCase(TestCase):
@@ -78,63 +75,3 @@ class BuildFarmTestCase(TestCase):
     def tearDown(self):
         shutil.rmtree(self.path)
         super(BuildFarmTestCase, self).tearDown()
-
-
-class ReadTreesFromConfTests(testtools.TestCase):
-
-    def create_file(self, contents):
-        (fd, path) = tempfile.mkstemp()
-        f = os.fdopen(fd, 'w')
-        self.addCleanup(os.remove, path)
-        try:
-            f.write(contents)
-        finally:
-            f.close()
-        return path
-
-    def test_read_trees_from_conf_ko(self):
-        name = self.create_file("""
-[foo]
-param1 = fooval1
-param2 = fooval2
-param3 = fooval3
-
-[bar]
-param1 = barval1
-param2 = barval2
-param3 = barval3
-""")
-        self.assertRaises(
-            Exception, data.read_trees_from_conf, name, None)
-
-    def test_read_trees_from_conf(self):
-        name = self.create_file("""
-[pidl]
-scm = git
-repo = samba.git
-branch = master
-subdir = pidl/
-
-[rsync]
-scm = git
-repo = rsync.git
-branch = HEAD
-""")
-        t = data.read_trees_from_conf(name)
-        self.assertEquals(
-            t["pidl"].scm,
-            "git")
-
-
-
-
-class BuildFarmTests(BuildFarmTestCase):
-
-    def setUp(self):
-        super(BuildFarmTests, self).setUp()
-        self.x = BuildFarm(self.path)
-
-    def test_has_host(self):
-        self.assertFalse(self.x.has_host("charis"))
-        self.create_mock_logfile("tdb", "charis", "cc")
-        self.assertTrue(self.x.has_host("charis"))
diff --git a/buildfarm/tests/test_buildfarm.py b/buildfarm/tests/test_buildfarm.py
new file mode 100644
index 0000000..9132445
--- /dev/null
+++ b/buildfarm/tests/test_buildfarm.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+# Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2010
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from buildfarm import (
+    BuildFarm,
+    data,
+    read_trees_from_conf,
+    )
+from buildfarm.tests import BuildFarmTestCase
+
+import os
+from testtools import TestCase
+import tempfile
+
+
+class ReadTreesFromConfTests(TestCase):
+
+    def create_file(self, contents):
+        (fd, path) = tempfile.mkstemp()
+        f = os.fdopen(fd, 'w')
+        self.addCleanup(os.remove, path)
+        try:
+            f.write(contents)
+        finally:
+            f.close()
+        return path
+
+    def test_read_trees_from_conf_ko(self):
+        name = self.create_file("""
+[foo]
+param1 = fooval1
+param2 = fooval2
+param3 = fooval3
+
+[bar]
+param1 = barval1
+param2 = barval2
+param3 = barval3
+""")
+        self.assertRaises(
+            Exception, read_trees_from_conf, name, None)
+
+    def test_read_trees_from_conf(self):
+        name = self.create_file("""
+[pidl]
+scm = git
+repo = samba.git
+branch = master
+subdir = pidl/
+
+[rsync]
+scm = git
+repo = rsync.git
+branch = HEAD
+""")
+        t = read_trees_from_conf(name)
+        self.assertEquals(
+            t["pidl"].scm,
+            "git")
+
+
+class BuildFarmTests(BuildFarmTestCase):
+
+    def setUp(self):
+        super(BuildFarmTests, self).setUp()
+        self.write_compilers(["cc"])
+        self.write_trees({"trivial": { "scm": "git", "repo": "git://foo", "branch": "master" }})
+        self.x = BuildFarm(self.path)
+
+    def test_get_new_builds_empty(self):
+        self.assertEquals([], list(self.x.get_new_builds()))
+
+    def test_lcov_status_none(self):
+        self.assertRaises(data.NoSuchBuildError, self.x.lcov_status, "trivial")
+
+    def test_tree(self):
+        self.assertEquals("trivial", self.x.trees["trivial"].name)
+        tree = self.x.trees["trivial"]
+        self.assertEquals("git", tree.scm)
+        self.assertEquals("git://foo", tree.repo)
+        self.assertEquals("master", tree.branch)
diff --git a/import-and-analyse.py b/import-and-analyse.py
old mode 100644
new mode 100755


-- 
build.samba.org


More information about the samba-cvs mailing list