1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
import urllib
from buildbot.status.web.base import HtmlResource, path_to_builder, \
path_to_build, css_classes
from buildbot.status.builder import Results
# /builders/$builder/builds/$buildnum/steps/$stepname
class StatusResourceBuildTest(HtmlResource):
pageTitle = "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)
|