[Buildbot-commits] buildbot/buildbot/status html.py,1.42,1.43

Brian Warner warner at users.sourceforge.net
Tue Oct 19 18:31:59 UTC 2004


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16992/buildbot/status

Modified Files:
	html.py 
Log Message:
(StatusResourceTestResults): display any
TestResults that the Build might have
(StatusResourceTestResult): and the logs for each TestResult
(StatusResourceBuild): add link from the per-build page


Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- html.py	14 Oct 2004 16:47:01 -0000	1.42
+++ html.py	19 Oct 2004 18:31:49 -0000	1.43
@@ -164,6 +164,65 @@
         except (IndexError, ValueError):
             return NoResource("No such Log '%s'" % logname)
 
+# $builder/builds/NN/tests/TESTNAME
+class StatusResourceTestResult(HtmlResource):
+    title = "Test Logs"
+
+    def __init__(self, name, result):
+        HtmlResource.__init__(self)
+        self.name = name
+        self.result = result
+
+    def body(self, request):
+        dotname = ".".join(self.name)
+        logs = self.result.getLogs()
+        lognames = logs.keys()
+        lognames.sort()
+        data = "<h1>%s</h1>\n" % html.escape(dotname)
+        for name in lognames:
+            data += "<h2>%s</h2>\n" % html.escape(name)
+            data += "<pre>" + logs[name] + "</pre>\n\n"
+
+        return data
+
+
+# $builder/builds/NN/tests
+class StatusResourceTestResults(HtmlResource):
+    title = "Test Results"
+
+    def __init__(self, results):
+        HtmlResource.__init__(self)
+        self.results = results
+
+    def body(self, request):
+        r = self.results
+        data = "<h1>Test Results</h1>\n"
+        data += "<ul>\n"
+        testnames = r.keys()
+        testnames.sort()
+        for name in testnames:
+            res = r[name]
+            dotname = ".".join(name)
+            data += " <li>%s: " % dotname
+            # TODO: this could break on weird test names. At the moment,
+            # test names only come from Trial tests, where the name
+            # components must be legal python names, but that won't always
+            # be a restriction.
+            url = request.childLink(dotname)
+            data += "<a href=\"%s\">%s</a>" % (url, " ".join(res.getText()))
+            data += "</li>\n"
+        data += "</ul>\n"
+        return data
+
+    def getChild(self, path, request):
+        try:
+            name = tuple(path.split("."))
+            result = self.results[name]
+            return StatusResourceTestResult(name, result)
+        except KeyError:
+            return NoResource("No such test name '%s'" % path)
+
+
 # $builder/builds/NN
 class StatusResourceBuild(HtmlResource):
     title = "Build"
@@ -181,7 +240,10 @@
                    html.escape(b.getReason())))
         if b.isFinished():
             data += "<h2>Results:</h2>"
-            data += " ".join(b.getText())
+            data += " ".join(b.getText()) + "\n"
+            if b.getTestResults():
+                url = request.childLink("tests")
+                data += "<h3><a href=\"%s\">test results</a></h3>\n" % url
         else:
             data += "<h2>Build In Progress</h2>"
 
@@ -201,6 +263,9 @@
         return data
 
     def getChild(self, path, request):
+        if path == "tests":
+            # TODO: this will collide with a step named 'tests'
+            return StatusResourceTestResults(self.build.getTestResults())
         stepname = path
         steps = self.build.getSteps()
         for s in steps:





More information about the Commits mailing list