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
|
from datetime import datetime
import xml.etree.ElementTree as ET
def junit(t):
testsuites = ET.Element('testsuites')
testsuite = ET.SubElement(testsuites, 'testsuite',
id = "0",
package = 'ghc',
tests = str(t.total_tests),
failures = str(len(t.unexpected_failures) + len(t.unexpected_stat_failures)),
errors = str(len(t.framework_failures)),
timestamp = datetime.now().isoformat())
for res_type, group in [('stat failure', t.unexpected_stat_failures),
('unexpected failure', t.unexpected_failures)]:
for (directory, testname, reason, way) in group:
testcase = ET.SubElement(testsuite, 'testcase',
classname = testname,
name = way)
result = ET.SubElement(testcase, 'failure',
type = res_type,
message = reason)
for (directory, testname, reason, way) in t.framework_failures:
testcase = ET.SubElement(testsuite, 'testcase',
classname = testname,
name = way)
result = ET.SubElement(testcase, 'error',
type = "framework failure",
message = reason)
for (directory, testname, way) in t.expected_passes:
testcase = ET.SubElement(testsuite, 'testcase',
classname = testname,
name = way)
return ET.ElementTree(testsuites)
|