[pypy-svn] r76891 - in pypy/build/bot2/pypybuildbot: . test

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 6 12:15:29 CEST 2010


Author: antocuni
Date: Mon Sep  6 12:15:27 2010
New Revision: 76891

Added:
   pypy/build/bot2/pypybuildbot/test/test_pypylist.py   (contents, props changed)
Modified:
   pypy/build/bot2/pypybuildbot/builds.py
   pypy/build/bot2/pypybuildbot/pypylist.py
   pypy/build/bot2/pypybuildbot/summary.py
Log:
- use both the branch and the revision to index the test summary

- display the test results in the nightly build page



Modified: pypy/build/bot2/pypybuildbot/builds.py
==============================================================================
--- pypy/build/bot2/pypybuildbot/builds.py	(original)
+++ pypy/build/bot2/pypybuildbot/builds.py	Mon Sep  6 12:15:27 2010
@@ -65,14 +65,20 @@
         summary = outcome.get_summary()        
         build_status = self.build.build_status
         builder = build_status.builder
-        if not hasattr(builder, 'summary_by_revision'):
-            builder.summary_by_revision = {}
+        properties = build_status.getProperties()
+        if not hasattr(builder, 'summary_by_branch_and_revision'):
+            builder.summary_by_branch_and_revision = {}
         try:
-            rev = build_status.getProperty('got_revision')
+            rev = properties['got_revision']
+            branch = properties['branch']
+            if branch is None:
+                branch = 'trunk'
+            if branch.endswith('/'):
+                branch = branch[:-1]
         except KeyError:
             return
         else:
-            builder.summary_by_revision[rev] = summary
+            builder.summary_by_branch_and_revision[(branch, rev)] = summary
         builder.saveYourself()
 
 # ________________________________________________________________

Modified: pypy/build/bot2/pypybuildbot/pypylist.py
==============================================================================
--- pypy/build/bot2/pypybuildbot/pypylist.py	(original)
+++ pypy/build/bot2/pypybuildbot/pypylist.py	Mon Sep  6 12:15:27 2010
@@ -1,35 +1,208 @@
-from twisted.web.static import File
+import os.path
+import datetime
+import itertools
 import re
+import py
+from twisted.web import resource
+from twisted.web.static import File, DirectoryLister
 
-# to get the desired order keep in mind that they are reversed at the end, so
-# the highest the value, the bigger the priority
-FEATURES = {
-    'jit':      100,
-    'nojit':     50,
-    'stackless': 10
-    }
+class PyPyTarball(object):
 
-PLATFORMS = {
-    'linux':    100,
-    'linux64':   50,
-    'win32':     10,
-    }
+    # to get the desired order keep in mind that they are reversed at the end,
+    # so the highest the value, the bigger the priority
+    FEATURES_PRIORITY = {
+        'jit':      100,
+        'nojit':     50,
+        'stackless': 10
+        }
+
+    PLATFORM_PRIORITY = {
+        'linux':    100,
+        'linux64':   50,
+        'osx':       30,
+        'win32':     10,
+        }
+
+    PLATFORMS = {
+        'linux':   'linux-x86-32',
+        'linux64': 'linux-x86-64',
+        'osx':     'macosx-x86-32',
+        'win32':   'win-x86-32',        
+        }
+
+    DESCRIPTIONS = {
+        'nojit':     'app-level',
+        'jit':       'jit',
+        'stackless': 'stackless-app-level',
+        }
+
+    def __init__(self, filename):
+        self.filename = filename
+        try:
+            self.parse_filename()
+        except ValueError:
+            self.exe = None
+            self.backend = None
+            self.features = None
+            self.rev = -1
+            self.platform = None
+
+    def parse_filename(self):
+        if not self.filename.endswith('.tar.bz2'):
+            raise ValueError
+        name = self.filename.replace('.tar.bz2', '')
+        self.exe, self.backend, self.features, self.rev, self.platform = name.split('-')
+
+    def key(self):
+        return (self.rev,
+                self.FEATURES_PRIORITY.get(self.features, -1),
+                self.PLATFORM_PRIORITY.get(self.platform, -1))
+
+    def get_builder_names(self):
+        platform = self.PLATFORMS.get(self.platform, self.platform)
+        description = self.DESCRIPTIONS.get(self.features, self.features)
+        own_builder = 'own-%s' % platform
+        app_builder = '%s-%s-%s-%s' % (self.exe, self.backend, description, platform)
+        return own_builder, app_builder
 
-def parsename(name):
-    # name is something like pypy-c-jit-75654-linux.tar.bz2
-    try:
-        name2 = name.replace('.tar.bz2', '')
-        exe, backend, features, rev, platform = name2.split('-')
-    except ValueError:
-        return '', name
-    else:
-        return rev, FEATURES.get(features, -1), PLATFORMS.get(platform, -1), name
 
 class PyPyList(File):
 
     def listNames(self):
         names = File.listNames(self)
-        items = map(parsename, names)
-        items.sort()
-        items.reverse()
-        return [item[-1] for item in items]
+        items = map(PyPyTarball, names)
+        items.sort(key=PyPyTarball.key, reverse=True)
+        return [item.filename for item in items]
+
+    def directoryListing(self):
+        def is_pypy_dir(names):
+            for name in names:
+                if name.startswith('pypy-c'):
+                    return True
+            return False
+        names = self.listNames()
+        if is_pypy_dir(names):
+            Listener = PyPyDirectoryLister
+        else:
+            Listener = DirectoryLister
+        return Listener(self.path,
+                        names,
+                        self.contentTypes,
+                        self.contentEncodings,
+                        self.defaultType)
+
+
+
+class PyPyDirectoryLister(DirectoryLister):
+    template = """<html>
+<head>
+<title>%(header)s</title>
+<style>
+.even        { background-color: #eee    }
+.odd         { background-color: #dedede }
+.even-passed { background-color: #caffd8 }
+.odd-passed  { background-color: #a3feba }
+.even-failed { background-color: #ffbbbb }
+.odd-failed  { background-color: #ff9797 }
+
+.icon { text-align: center }
+.listing {
+    margin-left: auto;
+    margin-right: auto;
+    width: 50%%;
+    padding: 0.1em;
+    }
+
+body { border: 0; padding: 0; margin: 0; background-color: #efefef; }
+h1 {padding: 0.1em; background-color: #777; color: white; border-bottom: thin white dashed;}
+td,th {padding-left: 0.5em; padding-right: 0.5em; }
+
+</style>
+</head>
+
+<body>
+<h1>%(header)s</h1>
+
+<table>
+    <thead>
+        <tr>
+            <th>Filename</th>
+            <th>Size</th>
+            <th>Date</th>
+            <th><i>own</i> tests</th>
+            <th><i>applevel</i> tests</th>
+        </tr>
+    </thead>
+    <tbody>
+%(tableContent)s
+    </tbody>
+</table>
+
+</body>
+</html>
+"""
+
+    linePattern = """<tr class="%(class)s">
+    <td><a href="%(href)s">%(text)s</a></td>
+    <td>%(size)s</td>
+    <td>%(date)s</td>
+    <td class="%(own_summary_class)s">%(own_summary)s</td>
+    <td class="%(app_summary_class)s">%(app_summary)s</td>
+</tr>
+"""
+
+    def render(self, request):
+        self.status = request.site.buildbot_service.getStatus()
+        return DirectoryLister.render(self, request)
+
+    def _buildTableContent(self, elements):
+        tableContent = []
+        rowClasses = itertools.cycle(['odd', 'even'])
+        for element, rowClass in zip(elements, rowClasses):
+            element["class"] = rowClass
+            result = self._add_test_results(element, rowClass)
+            tableContent.append(self.linePattern % element)
+        return tableContent
+
+    def _add_test_results(self, element, rowClass):
+        filename = element['href']
+        f = py.path.local(self.path).join(filename)
+        date = datetime.date.fromtimestamp(f.mtime())
+        element['date'] = date.isoformat()
+        t = PyPyTarball(filename)
+        own_builder, app_builder = t.get_builder_names()
+        own_summary = self._get_summary(own_builder, t.rev)
+        app_summary = self._get_summary(app_builder, t.rev)
+        element['own_summary'] = own_summary
+        element['app_summary'] = app_summary
+        element['own_summary_class'] = self._get_summary_class(own_summary, rowClass)
+        element['app_summary_class'] = self._get_summary_class(app_summary, rowClass)
+
+    def _get_summary_class(self, summary, rowClass):
+        if summary is None:
+            return rowClass
+        elif summary.is_ok():
+            return rowClass + '-passed'
+        else:
+            rowClass + '-failed'
+
+    def _get_branch(self):
+        parts = self.path.split(os.path.sep)
+        i = parts.index('nightly')
+        branch = os.path.sep.join(parts[i+1:])
+        return branch
+
+    def _get_summary(self, builder_name, rev):
+        try:
+            branch = self._get_branch()
+            builder = self.status.getBuilder(builder_name)
+            return builder.summary_by_branch_and_revision[(branch, rev)]
+        except (AttributeError, KeyError):
+            return None
+            # for testing
+            ## from pypybuildbot.summary import OutcomeSummary
+            ## import random
+            ## if random.choice([True, True, True, False]):
+            ##     return OutcomeSummary(1000, 0, 2, 4)
+            ## else:
+            ##     return OutcomeSummary(990, 10, 2, 4)

Modified: pypy/build/bot2/pypybuildbot/summary.py
==============================================================================
--- pypy/build/bot2/pypybuildbot/summary.py	(original)
+++ pypy/build/bot2/pypybuildbot/summary.py	Mon Sep  6 12:15:27 2010
@@ -30,6 +30,9 @@
         self.s = s # skipped
         self.x = x # xfailed
 
+    def is_ok(self):
+        return self.F == 0
+
     def __str__(self):
         return '%d, %d F, %d s, %d x' % (self.p, self.F, self.s, self.x)
 

Added: pypy/build/bot2/pypybuildbot/test/test_pypylist.py
==============================================================================
--- (empty file)
+++ pypy/build/bot2/pypybuildbot/test/test_pypylist.py	Mon Sep  6 12:15:27 2010
@@ -0,0 +1,67 @@
+from pypybuildbot.pypylist import PyPyTarball
+
+def test_pypytarball():
+    t = PyPyTarball('pypy-c-jit-75654-linux.tar.bz2')
+    assert t.filename == 'pypy-c-jit-75654-linux.tar.bz2'
+    assert t.exe == 'pypy'
+    assert t.backend == 'c'
+    assert t.features == 'jit'
+    assert t.rev == '75654'
+    assert t.platform == 'linux'
+
+def test_invalid_filename():
+    t = PyPyTarball('foo')
+    assert t.filename == 'foo'
+    assert t.exe == None
+    assert t.backend == None
+    assert t.features == None
+    assert t.rev == -1
+    assert t.platform == None
+    t2 = PyPyTarball('pypy-c-jit-75654-linux.tar.bz2')
+    assert t < t2
+
+def test_sort():
+    files = map(PyPyTarball, [
+            'pypy-c-jit-10000-linux.tar.bz2',
+            'pypy-c-jit-20000-linux.tar.bz2',
+            'pypy-c-nojit-10000-linux.tar.bz2',
+            'pypy-c-jit-10000-linux64.tar.bz2',
+            'pypy-c-jit-10000-win32.tar.bz2',
+            'pypy-c-stackless-10000-linux.tar.bz2',
+            ])
+
+    files.sort(key=PyPyTarball.key, reverse=True)
+    files = [f.filename for f in files]
+    assert files == [
+        'pypy-c-jit-20000-linux.tar.bz2',
+        'pypy-c-jit-10000-linux.tar.bz2',
+        'pypy-c-jit-10000-linux64.tar.bz2',
+        'pypy-c-jit-10000-win32.tar.bz2',
+        'pypy-c-nojit-10000-linux.tar.bz2',
+        'pypy-c-stackless-10000-linux.tar.bz2',
+        ]
+
+def test_builder_names():
+    t = PyPyTarball('pypy-c-jit-76867-linux.tar.bz2')
+    assert t.get_builder_names() == ('own-linux-x86-32',
+                                     'pypy-c-jit-linux-x86-32')
+
+    t = PyPyTarball('pypy-c-nojit-76867-linux.tar.bz2')
+    assert t.get_builder_names() == ('own-linux-x86-32',
+                                     'pypy-c-app-level-linux-x86-32')
+    
+    t = PyPyTarball('pypy-c-stackless-76867-linux.tar.bz2')
+    assert t.get_builder_names() == ('own-linux-x86-32',
+                                     'pypy-c-stackless-app-level-linux-x86-32')
+
+    t = PyPyTarball('pypy-c-jit-76867-osx.tar.bz2')
+    assert t.get_builder_names() == ('own-macosx-x86-32',
+                                     'pypy-c-jit-macosx-x86-32')
+
+    t = PyPyTarball('pypy-c-jit-76867-linux64.tar.bz2')
+    assert t.get_builder_names() == ('own-linux-x86-64',
+                                     'pypy-c-jit-linux-x86-64')
+
+    t = PyPyTarball('pypy-c-jit-76867-win32.tar.bz2')
+    assert t.get_builder_names() == ('own-win-x86-32',
+                                     'pypy-c-jit-win-x86-32')



More information about the Pypy-commit mailing list