[SCM] build.samba.org - branch master updated
Matthieu Patou
mat at samba.org
Fri Nov 5 13:09:43 MDT 2010
The branch, master has been updated
via 9ced472 Add unit tests for fixed bug
via fd66f7c Fix and improvements
via 62611cc add test files
from 9dc4ebb add basic host database.
http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9ced472403f0ba518b53589a31e58486afb472ff
Author: Matthieu Patou <mat at matws.net>
Date: Fri Nov 5 22:09:24 2010 +0300
Add unit tests for fixed bug
commit fd66f7c6564e9551286ad5251fc41f7abb1994f6
Author: Matthieu Patou <mat at matws.net>
Date: Fri Nov 5 22:07:42 2010 +0300
Fix and improvements
Fix pb with load_list and read_trees_from_conf
Make the standalone server serves static content too
commit 62611cc69ed7000ad03f79c15ce32a7a33cff7f2
Author: Matthieu Patou <mat at matws.net>
Date: Fri Nov 5 22:07:16 2010 +0300
add test files
-----------------------------------------------------------------------
Summary of changes:
buildfarm/data.py | 3 ++-
buildfarm/tests/test_data.py | 13 +++++++++++++
buildfarm/tests/test_util.py | 8 ++++++++
buildfarm/tests/testlist | 5 +++++
buildfarm/tests/testtree.conf | 9 +++++++++
buildfarm/tests/testtree2.conf | 10 ++++++++++
buildfarm/util.py | 4 +++-
web/build.py | 23 +++++++++++++++++++----
8 files changed, 69 insertions(+), 6 deletions(-)
create mode 100644 buildfarm/tests/testlist
create mode 100644 buildfarm/tests/testtree.conf
create mode 100644 buildfarm/tests/testtree2.conf
Changeset truncated at 500 lines:
diff --git a/buildfarm/data.py b/buildfarm/data.py
index b2c2aef..0593923 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -113,6 +113,7 @@ class Tree(object):
def __init__(self, name, scm, repo, branch, subdir="", srcdir=""):
self.name = name
self.repo = repo
+ self.scm = scm
self.branch = branch
self.subdir = subdir
self.srcdir = srcdir
@@ -291,7 +292,7 @@ def read_trees_from_conf(path):
cfp.readfp(open(path))
for s in cfp.sections():
ret[s] = Tree(name=s, **dict(cfp.items(s)))
- return s
+ return ret
class BuildResultStore(object):
diff --git a/buildfarm/tests/test_data.py b/buildfarm/tests/test_data.py
index 42d06f0..c689261 100755
--- a/buildfarm/tests/test_data.py
+++ b/buildfarm/tests/test_data.py
@@ -30,6 +30,19 @@ class NonexistantTests(unittest.TestCase):
self.assertRaises(
Exception, data.BuildResultStore, "somedirthatdoesn'texist", None)
+class MiscTests(unittest.TestCase):
+ def test_read_trees_from_conf_ko(self):
+ name = "%s/testtree.conf" % os.path.dirname(__file__)
+ 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__)
+ t = data.read_trees_from_conf(name)
+ self.assertEquals(
+ t["pidl"].scm,
+ "git")
+
class BuildResultStoreTests(BuildFarmTestCase):
diff --git a/buildfarm/tests/test_util.py b/buildfarm/tests/test_util.py
index eb2a475..b85c509 100755
--- a/buildfarm/tests/test_util.py
+++ b/buildfarm/tests/test_util.py
@@ -16,6 +16,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import unittest
+import os
from buildfarm import util
class CountLinesTests(unittest.TestCase):
@@ -43,6 +44,13 @@ 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):
+
+ def test_simple(self):
+ name = "%s/testlist" % os.path.dirname(__file__)
+ l = util.load_list(name)
+ self.assertEquals(4, len(l))
+ self.assertEquals("three", l[2])
class StripHtmlTests(unittest.TestCase):
diff --git a/buildfarm/tests/testlist b/buildfarm/tests/testlist
new file mode 100644
index 0000000..bdd1fd3
--- /dev/null
+++ b/buildfarm/tests/testlist
@@ -0,0 +1,5 @@
+one
+two
+three
+
+for
diff --git a/buildfarm/tests/testtree.conf b/buildfarm/tests/testtree.conf
new file mode 100644
index 0000000..7d0feb8
--- /dev/null
+++ b/buildfarm/tests/testtree.conf
@@ -0,0 +1,9 @@
+[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
new file mode 100644
index 0000000..09bc186
--- /dev/null
+++ b/buildfarm/tests/testtree2.conf
@@ -0,0 +1,10 @@
+[pidl]
+scm = git
+repo = samba.git
+branch = master
+subdir = pidl/
+
+[rsync]
+scm = git
+repo = rsync.git
+branch = HEAD
diff --git a/buildfarm/util.py b/buildfarm/util.py
index 4b24fe5..83346c1 100644
--- a/buildfarm/util.py
+++ b/buildfarm/util.py
@@ -26,7 +26,9 @@ def load_list(fname):
try:
for l in f.readlines():
if l[0] != "#":
- ret.append(l)
+ l = l.strip('\r\n')
+ if len(l) > 0:
+ ret.append(l)
finally:
f.close()
return ret
diff --git a/web/build.py b/web/build.py
index 3b8aa50..e31871d 100755
--- a/web/build.py
+++ b/web/build.py
@@ -35,7 +35,7 @@ import re
import time
import wsgiref.util
-
+standalone = 0
webdir = os.path.dirname(__file__)
basedir = os.path.abspath(os.path.join(webdir, ".."))
@@ -102,7 +102,7 @@ def html_build_status(status):
return "%s/%s/%s/%s%s" % (span_status(cstatus), span_status(bstatus), span_status(istatus), span_status(tstatus), ostatus)
-def build_status(myself, tree, host, compiler, rev):
+def build_status(myself, tree, host, compiler, rev=None):
build = db.get_build(tree, host, compiler, rev)
status = html_build_status(build.status())
return build_link(myself, tree, host, compiler, rev, status)
@@ -227,7 +227,7 @@ def tree_link(myself, tree):
# return a link to a particular tree
branch = ""
if tree in trees:
- branch = ":%s" % trees[tree]["branch"]
+ branch = ":%s" % trees[tree].branch
return "<a href='%s?function=Recent+Builds;tree=%s' title='View recent builds for %s'>%s%s</a>" % (myself, tree, tree, tree, branch)
@@ -864,6 +864,21 @@ def buildApp(environ, start_response):
fn_name = get_param(form, 'function') or ''
myself = wsgiref.util.application_uri(environ)
+ if standalone and environ['PATH_INFO']:
+ dir = os.path.join(os.path.dirname(__file__))
+ static_file = "%s/%s" % (dir, environ['PATH_INFO'])
+ if os.path.exists(static_file):
+ tab = environ['PATH_INFO'].split('.')
+ if len(tab) > 1:
+ extension = tab[-1]
+ import mimetypes
+ mimetypes.init()
+ type = mimetypes.types_map[".%s" % extension]
+ start_response('200 OK', [('Content-type', type)])
+ data = open(static_file, 'rb').read()
+ yield data
+ return
+
if fn_name == 'text_diff':
start_response('200 OK', [('Content-type', 'application/x-diff')])
(title, entry, tree, diffs) = history.diff(get_param(form, 'author'),
@@ -895,7 +910,6 @@ def buildApp(environ, start_response):
yield util.FileLoad(os.path.join(webdir, "header2.html"))
yield "".join(main_menu())
yield util.FileLoad(os.path.join(webdir, "header3.html"))
-
if fn_name == "View_Build":
plain_logs = (get_param(form, "plain") is not None and get_param(form, "plain").lower() in ("yes", "1", "on", "true", "y"))
yield "".join(view_build(myself, get_param(form, "tree"), get_param(form, "host"),
@@ -953,6 +967,7 @@ if __name__ == '__main__':
parser.add_option("--standalone", help="Run as standalone server (useful for debugging)", action="store_true")
opts, args = parser.parse_args()
if opts.standalone:
+ standalone = 1
from wsgiref.simple_server import make_server
httpd = make_server('', 8000, buildApp)
print "Serving on port 8000..."
--
build.samba.org
More information about the samba-cvs
mailing list