blob: b96bba2225f4a03d7efa7bf9ea0193c0aec01adf (
plain)
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
|
from twisted.web.error import NoResource
from twisted.web import html
from buildbot.status.web.base import HtmlResource
# /builders/$builder/builds/$buildnum/tests/$testname
class TestResult(HtmlResource):
title = "Test Logs"
def __init__(self, name, test_result):
HtmlResource.__init__(self)
self.name = name
self.test_result = test_result
def body(self, request):
dotname = ".".join(self.name)
logs = self.test_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
# /builders/$builder/builds/$buildnum/tests
class TestsResource(HtmlResource):
title = "Test Results"
def __init__(self, build_status):
HtmlResource.__init__(self)
self.build_status = build_status
self.test_results = build_status.getTestResults()
def body(self, request):
r = self.test_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.test_results[name]
return TestResult(name, result)
except KeyError:
return NoResource("No such test name '%s'" % path)
|