[SCM] build.samba.org - branch master updated
Jelmer Vernooij
jelmer at samba.org
Fri Nov 5 20:26:16 MDT 2010
The branch, master has been updated
via 6505499 Inline test data.
via 9bce367 PEP8
via 9f62c2b Add more tests.
via a72e3d2 Default rev to None, consistent with other code.
from 2b9b526 Fix a bug
http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 65054993bf7cf96f17517bcc7edcc3db32de0667
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Nov 5 20:29:36 2010 +0100
Inline test data.
commit 9bce36774b255246de091ad7a5810a72d9689d0c
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Nov 5 20:16:41 2010 +0100
PEP8
commit 9f62c2bee32bac90800a8925223c2ebb9491ad9d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Nov 5 20:10:17 2010 +0100
Add more tests.
commit a72e3d2abecf16202750a8a4b448a6fe5a1c0786
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Nov 5 20:04:43 2010 +0100
Default rev to None, consistent with other code.
-----------------------------------------------------------------------
Summary of changes:
buildfarm/data.py | 37 ++---------------------
buildfarm/tests/test_data.py | 63 ++++++++++++++++++++++++++++++++++++++--
buildfarm/tests/test_util.py | 24 ++++++++++++---
buildfarm/tests/testlist | 5 ---
buildfarm/tests/testtree.conf | 9 ------
buildfarm/tests/testtree2.conf | 10 ------
6 files changed, 82 insertions(+), 66 deletions(-)
delete mode 100644 buildfarm/tests/testlist
delete mode 100644 buildfarm/tests/testtree.conf
delete mode 100644 buildfarm/tests/testtree2.conf
Changeset truncated at 500 lines:
diff --git a/buildfarm/data.py b/buildfarm/data.py
index e2502d2..8a2ce6c 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -86,8 +86,7 @@ def build_status_from_logs(log, err):
else:
sstatus = None
- return {"config": cstatus, "build": bstatus, "install": istatus,\
- "test": tstatus, "checker": sstatus, "other": other_failures}
+ return ((cstatus, bstatus, istatus, tstatus, sstatus), other_failures)
def lcov_extract_percentage(text):
@@ -262,34 +261,6 @@ class CachingBuild(Build):
return ret
- def unmarshall_status(self, cnt):
- tab = cnt.split('\n')
- hash = {}
- for l in tab:
- tab2 = l.split(':', 1)
- if tab2[0] == "other":
- tab3 = []
- if len(tab2) > 1:
- tab3 = tab2[1].split('%')
- hash[tab2[0]] = tab3
- else:
- if tab2[1] == "None":
- hash[tab2[0]] = tab2[1]
- else:
- hash[tab2[0]] = None
-
- return hash
-
- def marshall_status(self, val):
- tab = []
- for k in val.keys():
- if k != "other":
- tab.append("%s:%s" % (k, val[k]))
- else:
- tab.append("%s:%s" % (k, "%".join(val[k])))
-
- return "\n".join(tab)
-
def status(self):
file = self._store.build_fname(self.tree, self.host, self.compiler, self.rev)
cachefile = self._store.cache_fname(self.tree, self.host, self.compiler, self.rev)+".status"
@@ -303,14 +274,12 @@ class CachingBuild(Build):
st2 = None
if st2 and st1.st_ctime <= st2.st_mtime:
- cnt = util.FileLoad(cachefile)
- return self.unmarshall_status(cnt)
+ return eval(util.FileLoad(cachefile))
ret = super(CachingBuild, self).status()
if not self._store.readonly:
- cnt = self.marshall_status(ret)
- util.FileSave(cachefile, cnt)
+ util.FileSave(cachefile, repr(ret))
return ret
diff --git a/buildfarm/tests/test_data.py b/buildfarm/tests/test_data.py
index c689261..2ce5198 100755
--- a/buildfarm/tests/test_data.py
+++ b/buildfarm/tests/test_data.py
@@ -16,6 +16,8 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
+import tempfile
+import testtools
import time
import unittest
@@ -30,14 +32,47 @@ class NonexistantTests(unittest.TestCase):
self.assertRaises(
Exception, data.BuildResultStore, "somedirthatdoesn'texist", None)
-class MiscTests(unittest.TestCase):
+
+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 = "%s/testtree.conf" % os.path.dirname(__file__)
+ 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 = "%s/testtree2.conf" % os.path.dirname(__file__)
+ 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,
@@ -135,3 +170,25 @@ error3""")
self.assertFalse(self.x.has_host("charis"))
self.create_mock_logfile("tdb", "charis", "cc")
self.assertTrue(self.x.has_host("charis"))
+
+
+
+class LogParserTests(unittest.TestCase):
+
+ def test_nothing(self):
+ self.assertEquals(((None, None, None, None, None), set()),
+ data.build_status_from_logs("", ""))
+
+ def test_disk_full(self):
+ self.assertEquals(((None, None, None, None, None), set(["disk full"])),
+ data.build_status_from_logs("foo\nbar\nNo space left on device\nla\n",
+ ""))
+ self.assertEquals(((None, None, None, None, None), set(["disk full"])),
+ data.build_status_from_logs(
+ "", "foo\nbar\nNo space left on device\nla\n"))
+
+ def test_timeout(self):
+ self.assertEquals(((None, None, None, None, None), set(["timeout"])),
+ data.build_status_from_logs("foo\nbar\nmaximum runtime exceeded\nla\n",
+ ""))
+
diff --git a/buildfarm/tests/test_util.py b/buildfarm/tests/test_util.py
index b85c509..3a1d5a4 100755
--- a/buildfarm/tests/test_util.py
+++ b/buildfarm/tests/test_util.py
@@ -5,18 +5,21 @@
# 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.
-import unittest
import os
+import tempfile
+import testtools
+import unittest
+
from buildfarm import util
class CountLinesTests(unittest.TestCase):
@@ -44,14 +47,25 @@ class DhmTimeTests(unittest.TestCase):
self.assertEquals("1d 3h 1m", util.dhm_time(97265))
self.assertEquals("3h 1m", util.dhm_time(10865))
-class LoadTests(unittest.TestCase):
+
+class LoadTests(testtools.TestCase):
def test_simple(self):
- name = "%s/testlist" % os.path.dirname(__file__)
+ fd, name = tempfile.mkstemp()
+ self.addCleanup(os.remove, name)
+ f = os.fdopen(fd, 'w')
+ f.write("""one
+two
+three
+
+for
+""")
+ f.close()
l = util.load_list(name)
self.assertEquals(4, len(l))
self.assertEquals("three", l[2])
+
class StripHtmlTests(unittest.TestCase):
def test_simple(self):
diff --git a/buildfarm/tests/testlist b/buildfarm/tests/testlist
deleted file mode 100644
index bdd1fd3..0000000
--- a/buildfarm/tests/testlist
+++ /dev/null
@@ -1,5 +0,0 @@
-one
-two
-three
-
-for
diff --git a/buildfarm/tests/testtree.conf b/buildfarm/tests/testtree.conf
deleted file mode 100644
index 7d0feb8..0000000
--- a/buildfarm/tests/testtree.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-[foo]
-param1 = fooval1
-param2 = fooval2
-param3 = fooval3
-
-[bar]
-param1 = barval1
-param2 = barval2
-param3 = barval3
diff --git a/buildfarm/tests/testtree2.conf b/buildfarm/tests/testtree2.conf
deleted file mode 100644
index 09bc186..0000000
--- a/buildfarm/tests/testtree2.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-[pidl]
-scm = git
-repo = samba.git
-branch = master
-subdir = pidl/
-
-[rsync]
-scm = git
-repo = rsync.git
-branch = HEAD
--
build.samba.org
More information about the samba-cvs
mailing list