Don't shadow "result" in JUnit driver
[ghc.git] / testsuite / driver / junit.py
1 from datetime import datetime
2 import xml.etree.ElementTree as ET
3
4 def junit(t):
5 testsuites = ET.Element('testsuites')
6 testsuite = ET.SubElement(testsuites, 'testsuite',
7 id = "0",
8 package = 'ghc',
9 tests = str(t.total_tests),
10 failures = str(len(t.unexpected_failures) + len(t.unexpected_stat_failures)),
11 errors = str(len(t.framework_failures)),
12 timestamp = datetime.now().isoformat())
13
14 for res_type, group in [('stat failure', t.unexpected_stat_failures),
15 ('unexpected failure', t.unexpected_failures)]:
16 for (directory, testname, reason, way) in group:
17 testcase = ET.SubElement(testsuite, 'testcase',
18 classname = testname,
19 name = way)
20 result = ET.SubElement(testcase, 'failure',
21 type = res_type,
22 message = reason)
23
24 for (directory, testname, reason, way) in t.framework_failures:
25 testcase = ET.SubElement(testsuite, 'testcase',
26 classname = testname,
27 name = way)
28 result = ET.SubElement(testcase, 'error',
29 type = "framework failure",
30 message = reason)
31
32 for (directory, testname, way) in t.expected_passes:
33 testcase = ET.SubElement(testsuite, 'testcase',
34 classname = testname,
35 name = way)
36
37 return ET.ElementTree(testsuites)
38