Skip to content

Commit

Permalink
web-status: implement test results page
Browse files Browse the repository at this point in the history
The build page refers to the tests/ child, but this hadn't been implemented.
  • Loading branch information
xrg authored and Dustin J. Mitchell committed Oct 3, 2010
1 parent 3c7ee77 commit 0160f27
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
3 changes: 3 additions & 0 deletions master/buildbot/status/web/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
getAndCheckProperties, path_to_authfail

from buildbot.status.web.step import StepsResource
from buildbot.status.web.tests import TestsResource
from buildbot import util, interfaces


Expand Down Expand Up @@ -210,6 +211,8 @@ def getChild(self, path, req):
return self.rebuild(req)
if path == "steps":
return StepsResource(self.build_status)
if path == "tests":
return TestsResource(self.build_status)

return HtmlResource.getChild(self, path, req)

Expand Down
34 changes: 34 additions & 0 deletions master/buildbot/status/web/templates/testresult.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "layout.html" %}

{% block content %}

<h1>
Builder <a href="{{ builder_link }}">{{ b.getBuilder().getName() }}</a>
build <a href="{{ build_link }}">#{{ b.getNumber() }}</a>
test <a href="">{{ '.'.join(tr.getName()) }}</a>
</h1>

<div class="column">

<h2>Result</h2>
<p class="{{ result_css }} result">
{{ result_word }}
{%- set text = tr.getText() -%}
{%- if text is string %}{{ text|e }}
{%- else %}{{ text|join(" ")|e }}{% endif -%}
</p>

<h2>Logs</h2>
<ul>
{% for l in logs %}
<h3>Log: {{ l.name|e }}</h3>
<samp><pre>{{ l.log|e }}</pre></samp>
</br>
{% else %}
<li class="alt">- No logs -</li>
{% endfor %}
</ul>

</div>

{% endblock %}
72 changes: 72 additions & 0 deletions master/buildbot/status/web/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

import urllib
from buildbot.status.web.base import HtmlResource, path_to_builder, \
path_to_build, css_classes
from buildbot.status.web.logs import LogsResource
from buildbot.status.builder import Results
from buildbot import util
from time import ctime

# /builders/$builder/builds/$buildnum/steps/$stepname
class StatusResourceBuildTest(HtmlResource):
title = "Test Result"
addSlash = True

def __init__(self, build_status, test_result):
HtmlResource.__init__(self)
self.status = build_status
self.test_result = test_result

def content(self, req, cxt):
tr = self.test_result
b = self.status

cxt['b'] = self.status
logs = cxt['logs'] = []
for lname, log in tr.getLogs().items():
if isinstance(log, str):
log = log.decode('utf-8')
logs.append({'name': lname,
'log': log,
'link': req.childLink("logs/%s" % urllib.quote(lname)) })

cxt['text'] = tr.text
cxt['result_word'] = Results[tr.getResults()]
cxt.update(dict(builder_link = path_to_builder(req, b.getBuilder()),
build_link = path_to_build(req, b),
result_css = css_classes[tr.getResults()],
b = b,
tr = tr))

template = req.site.buildbot_service.templates.get_template("testresult.html")
return template.render(**cxt)

def getChild(self, path, req):
# if path == "logs":
# return LogsResource(self.step_status) #TODO we need another class
return HtmlResource.getChild(self, path, req)



# /builders/$builder/builds/$buildnum/steps
class TestsResource(HtmlResource):
addSlash = True
nameDelim = '.' # Test result have names like a.b.c

def __init__(self, build_status):
HtmlResource.__init__(self)
self.build_status = build_status

def content(self, req, ctx):
# TODO list the tests
return "subpages show data for each test"

def getChild(self, path, req):
tpath = None
if path:
tpath = tuple(path.split(self.nameDelim))
if tpath:
tr = self.build_status.getTestResults().get(tpath)
if tr:
return StatusResourceBuildTest(self.build_status, tr)
return HtmlResource.getChild(self, path, req)

0 comments on commit 0160f27

Please sign in to comment.