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

Jelmer Vernooij jelmer at samba.org
Mon Nov 15 15:07:06 MST 2010


The branch, master has been updated
       via  0cb42c2 Add buildfarm.web tests.
       via  c9e91d3 Fix exception handling when both python-pysqlite2 and sqlite3 are installed.
      from  a6c0f05 Decode host names and platform name.

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


- Log -----------------------------------------------------------------
commit 0cb42c2abd1c95df648dd359ef47a0ab4f1bd917
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Mon Nov 15 16:30:50 2010 +0100

    Add buildfarm.web tests.

commit c9e91d3e26de7183996455148920fb1c20163fd2
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Mon Nov 15 16:30:36 2010 +0100

    Fix exception handling when both python-pysqlite2 and sqlite3 are installed.

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

Summary of changes:
 buildfarm/sqldb.py                                |    4 +-
 buildfarm/web/__init__.py                         |   71 +++++++++++----------
 web/build.cgi => buildfarm/web/tests/test_util.py |   26 +++-----
 3 files changed, 49 insertions(+), 52 deletions(-)
 create mode 100644 buildfarm/web/tests/__init__.py
 copy web/build.cgi => buildfarm/web/tests/test_util.py (55%)
 mode change 100755 => 100644


Changeset truncated at 500 lines:

diff --git a/buildfarm/sqldb.py b/buildfarm/sqldb.py
index 8c5330f..e0ef491 100644
--- a/buildfarm/sqldb.py
+++ b/buildfarm/sqldb.py
@@ -35,9 +35,9 @@ from buildfarm.hostdb import (
 
 import os
 try:
-    import sqlite3
-except ImportError:
     from pysqlite2 import dbapi2 as sqlite3
+except ImportError:
+    import sqlite3
 from storm.database import create_database
 from storm.locals import Bool, Desc, Int, Unicode, RawStr
 from storm.store import Store
diff --git a/buildfarm/web/__init__.py b/buildfarm/web/__init__.py
index 33165dc..dda4b17 100755
--- a/buildfarm/web/__init__.py
+++ b/buildfarm/web/__init__.py
@@ -682,6 +682,41 @@ class ViewRecentBuildsPage(BuildFarmPage):
 
 class ViewHostPage(BuildFarmPage):
 
+    def _render_build(self, myself, build):
+        try:
+            (revision, revision_time) = build.revision_details()
+        except data.MissingRevisionInfo:
+            revision = None
+        age_mtime = build.age_mtime()
+        age_ctime = build.age_ctime()
+        warnings = build.err_count()
+        status = build_status_html(myself, build)
+        if row == 0:
+            if output_type == 'text':
+                yield "%-12s %-10s %-10s %-10s %-10s\n" % (
+                        "Tree", "Compiler", "Build Age", "Status", "Warnings")
+            else:
+                yield "<div class='host summary'>"
+                yield "<a id='host' name='host'/>"
+                yield "<h3>%s - %s</h3>" % (host, self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
+                yield "<table class='real'>"
+                yield "<thead><tr><th>Target</th><th>Build<br/>Revision</th><th>Build<br />Age</th><th>Status<br />config/build<br />install/test</th><th>Warnings</th></tr></thead>"
+                yield "<tbody>"
+
+        if output_type == 'text':
+            yield "%-12s %-10s %-10s %-10s %-10s\n" % (
+                    tree, compiler, util.dhm_time(age_mtime),
+                    util.strip_html(status), warnings)
+        else:
+            yield "<tr>"
+            yield "<td><span class='tree'>" + self.tree_link(myself, tree) +"</span>/" + compiler + "</td>"
+            yield "<td>" + revision_link(myself, revision, tree) + "</td>"
+            yield "<td><div class='age'>" + self.red_age(age_mtime) + "</div></td>"
+            yield "<td><div class='status'>%s</div></td>" % status
+            yield "<td>%s</td>" % warnings
+            yield "</tr>"
+        row+=1
+
     def render(self, myself, output_type, *requested_hosts):
         """print the host's table of information"""
 
@@ -699,7 +734,6 @@ class ViewHostPage(BuildFarmPage):
                 continue
 
             row = 0
-
             for compiler in self.buildfarm.compilers:
                 for tree in sorted(self.buildfarm.trees.keys()):
                     try:
@@ -707,39 +741,8 @@ class ViewHostPage(BuildFarmPage):
                     except data.NoSuchBuildError:
                         pass
                     else:
-                        try:
-                            (revision, revision_time) = build.revision_details()
-                        except data.MissingRevisionInfo:
-                            revision = None
-                        age_mtime = build.age_mtime()
-                        age_ctime = build.age_ctime()
-                        warnings = build.err_count()
-                        status = build_status_html(myself, build)
-                        if row == 0:
-                            if output_type == 'text':
-                                yield "%-12s %-10s %-10s %-10s %-10s\n" % (
-                                        "Tree", "Compiler", "Build Age", "Status", "Warnings")
-                            else:
-                                yield "<div class='host summary'>"
-                                yield "<a id='host' name='host'/>"
-                                yield "<h3>%s - %s</h3>" % (host, self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
-                                yield "<table class='real'>"
-                                yield "<thead><tr><th>Target</th><th>Build<br/>Revision</th><th>Build<br />Age</th><th>Status<br />config/build<br />install/test</th><th>Warnings</th></tr></thead>"
-                                yield "<tbody>"
-
-                        if output_type == 'text':
-                            yield "%-12s %-10s %-10s %-10s %-10s\n" % (
-                                    tree, compiler, util.dhm_time(age_mtime),
-                                    util.strip_html(status), warnings)
-                        else:
-                            yield "<tr>"
-                            yield "<td><span class='tree'>" + self.tree_link(myself, tree) +"</span>/" + compiler + "</td>"
-                            yield "<td>" + revision_link(myself, revision, tree) + "</td>"
-                            yield "<td><div class='age'>" + self.red_age(age_mtime) + "</div></td>"
-                            yield "<td><div class='status'>%s</div></td>" % status
-                            yield "<td>%s</td>" % warnings
-                            yield "</tr>"
-                        row+=1
+                        self._render_build(myself, build)
+
             if row != 0:
                 if output_type == 'text':
                     yield "\n"
diff --git a/buildfarm/web/tests/__init__.py b/buildfarm/web/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/web/build.cgi b/buildfarm/web/tests/test_util.py
old mode 100755
new mode 100644
similarity index 55%
copy from web/build.cgi
copy to buildfarm/web/tests/test_util.py
index 3f6b295..d507edd
--- a/web/build.cgi
+++ b/buildfarm/web/tests/test_util.py
@@ -1,7 +1,5 @@
 #!/usr/bin/python
-# This CGI script presents the results of the build_farm build
-
-# Copyright (C) Jelmer Vernooij <jelmer at samba.org>     2010
+# 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
@@ -17,19 +15,15 @@
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
+import testtools
+from buildfarm.web import build_link
+
+
+class BuildLinkTests(testtools.TestCase):
 
-from buildfarm.filecache import CachingBuildFarm
-from buildfarm.web import BuildFarmApp
-import wsgiref.handlers
-import resource
+    def test_build_link_no_rev(self):
+        self.assertEquals("<a href='myself?function=View+Build;host=charis;tree=tdb;compiler=gcc'>status</a>", build_link("myself", "tdb", "charis", "gcc", None, "status"))
 
-resource.setrlimit(resource.RLIMIT_RSS, (300000, 300000))
-resource.setrlimit(resource.RLIMIT_DATA, (300000, 300000))
 
-buildfarm = CachingBuildFarm()
-buildApp = BuildFarmApp(buildfarm)
-handler = wsgiref.handlers.CGIHandler()
-handler.run(buildApp)
+    def test_build_link_rev(self):
+        self.assertEquals("<a href='myself?function=View+Build;host=charis;tree=tdb;compiler=gcc;revision=42'>status</a>", build_link("myself", "tdb", "charis", "gcc", "42", "status"))


-- 
build.samba.org


More information about the samba-cvs mailing list