2 from twisted
.web
.error
import NoResource
3 from twisted
.web
import html
5 from buildbot
.status
.web
.base
import HtmlResource
7 # $builder/builds/NN/tests/TESTNAME
8 class TestResult(HtmlResource
):
11 def __init__(self
, name
, test_result
):
12 HtmlResource
.__init
__(self
)
14 self
.test_result
= test_result
16 def body(self
, request
):
17 dotname
= ".".join(self
.name
)
18 logs
= self
.test_result
.getLogs()
19 lognames
= logs
.keys()
21 data
= "<h1>%s</h1>\n" % html
.escape(dotname
)
23 data
+= "<h2>%s</h2>\n" % html
.escape(name
)
24 data
+= "<pre>" + logs
[name
] + "</pre>\n\n"
29 # $builder/builds/NN/tests
30 class TestsResource(HtmlResource
):
31 title
= "Test Results"
33 def __init__(self
, build_status
):
34 HtmlResource
.__init
__(self
)
35 self
.build_status
= build_status
36 self
.test_results
= build_status
.getTestResults()
38 def body(self
, request
):
40 data
= "<h1>Test Results</h1>\n"
44 for name
in testnames
:
46 dotname
= ".".join(name
)
47 data
+= " <li>%s: " % dotname
48 # TODO: this could break on weird test names. At the moment,
49 # test names only come from Trial tests, where the name
50 # components must be legal python names, but that won't always
52 url
= request
.childLink(dotname
)
53 data
+= "<a href=\"%s\">%s</a>" % (url
, " ".join(res
.getText()))
58 def getChild(self
, path
, request
):
60 name
= tuple(path
.split("."))
61 result
= self
.test_results
[name
]
62 return TestResult(name
, result
)
64 return NoResource("No such test name '%s'" % path
)