[pypy-svn] r50683 - pypy/build/buildbot

exarkun at codespeak.net exarkun at codespeak.net
Wed Jan 16 20:32:44 CET 2008


Author: exarkun
Date: Wed Jan 16 20:32:44 2008
New Revision: 50683

Modified:
   pypy/build/buildbot/pypy_status.py
Log:
version of the html status thing which really works

this generates a table of the results of tests across different builders for
recent builds which includes only tests which have failed recently


Modified: pypy/build/buildbot/pypy_status.py
==============================================================================
--- pypy/build/buildbot/pypy_status.py	(original)
+++ pypy/build/buildbot/pypy_status.py	Wed Jan 16 20:32:44 2008
@@ -5,57 +5,73 @@
 from nevow.url import URL
 from nevow.flat import flatten
 
+from buildbot.interfaces import LOG_CHANNEL_STDOUT
 from buildbot.status.web.base import ICurrentBox, HtmlResource, map_branches, build_get_class
 
 class RecentlyFailingTests(HtmlResource):
+    oldBuildCount = 10
+
+    def getLog(self, build, name):
+        for log in build.getLogs():
+            if log.name.endswith(name):
+                stdout = ''.join(
+                    log.getChunks(channels=[LOG_CHANNEL_STDOUT],
+                                  onlyText=True))
+                return stdout
+        return ''
+
     def body(self, request):
-        status = self.getStatus(req)
+        status = self.getStatus(request)
         builderNames = status.getBuilderNames()
-
-        # Keys are the names of tests which failed recently.  Each
-        # value is a list the elements of which is a group of test
-        # results for a particular build.  The group is a dict the
-        # keys of which are a builder name and the values of which are
-        # the result for that test on that builder for that build.
-        # eg
-        #
-        # {'foo.tests.test_foo.FooTests.test_foo': [
-        #     {'win32': 'passed', 'linux': 'failed'},
-        #     {'win32': 'passed', 'linux': 'passed'},
-        #     {'win32': 'failed', 'linux': 'passed'}]}
 	failedTests = {}
 
         for name in builderNames:
             recentFailures = Set()
             builder = status.getBuilder(name)
-            recentBuilds = builder.generateFinishedBuilds(branches=[None], num_builds=10)
+            recentBuilds = builder.generateFinishedBuilds(
+                branches=[None], num_builds=self.oldBuildCount)
             for build in recentBuilds:
-                recentFailures.update(build.getLog('failed').splitlines())
+                print build
+                recentFailures.update(self.getLog(build, 'failed').splitlines())
 
-        for name in builderNames:
-            builder = status.getBuilder(name)
-            recentBuilds = builder.generateFinishedBuilds(branches=[None], num_builds=10)
-            for build in recentBuilds:
-                results = {}
-                for passed in build.getLog('passed').splitlines():
-                    results[passed] = 'passed'
-                for failed in build.getLog('failed').splitlines():
-                    results[failed] = 'failed'
-                for skipped in build.getLog('skipped').splitlines():
-                    results[skipped] = 'skipped'
-                for recentFailed in recentFailures:
-                    
-
-                
-
-        table = tags.table[[
-                tags.tr[[
-                        tags.td[[
-                                testResult[0]
-                                for testResult
-                                in testResultsForBuild],
-                            tags.td[testName]]
-                        for testResultsForBuild
-                        in testResultsOverTime]]
-                    for (testName, testResultsOverTime)
-                    in failedTests.iteritems()]]
+        for builderName in builderNames:
+            builder = status.getBuilder(builderName)
+            recentBuilds = builder.generateFinishedBuilds(
+                branches=[None], num_builds=self.oldBuildCount)
+            for buildNumber, build in enumerate(recentBuilds):
+                results = dict.fromkeys(
+                    self.getLog(build, 'passed').splitlines(),
+                    tags.span(style="background-color: green;")['P'])
+                results.update(
+                    dict.fromkeys(
+                        self.getLog(build, 'failed').splitlines(),
+                        tags.span(style="background-color: red;")['F']))
+                results.update(
+                    dict.fromkeys(
+                        self.getLog(build, 'skipped').splitlines(),
+                        tags.span(style="background-color: yellow;")['S']))
+
+                for testName in recentFailures:
+                    key = (builderName, buildNumber, testName)
+                    failedTests[key] = results.get(
+                        testName,
+                        tags.span(style="background-color: cyan;")['?'])
+
+        table = tags.table()
+        heading = tags.tr()
+        for buildNumber in range(self.oldBuildCount):
+            heading[tags.td()[buildNumber]]
+        table[heading]
+
+        for testName in recentFailures:
+            row = tags.tr()
+            for buildNumber in range(self.oldBuildCount):
+                result = []
+                for builderName in builderNames:
+                    key = (builderName, buildNumber, testName)
+                    result.append(failedTests[key])
+                row[tags.td()[result]]
+            row[tags.td()[testName]]
+            table[row]
+
+        return flatten(table)



More information about the Pypy-commit mailing list