11 from __future__
import print_function
15 from junit_xml
import TestSuite, TestCase
16 from ReporterMTTStage
import *
30 ReporterMTTStage.__init__(self)
32 self.
options[
'filename'] = (
None,
"Name of the file into which the report is to be written")
33 self.
options[
'textwrap'] = (
"80",
"Max line length before wrapping")
38 IPlugin.activate(self)
42 IPlugin.deactivate(self)
49 lines = testDef.printOptions(self.
options)
55 testDef.logger.verbose_print(
"JunitXML Reporter")
58 testDef.parseOptions(log, self.
options, keyvals, cmds)
59 if cmds[
'filename']
is not None:
60 self.
fh = open(cmds[
'filename']
if os.path.isabs(cmds[
'filename']) \
61 else os.path.join(cmds[
'scratch'],cmds[
'filename']),
'w')
62 if testDef.options[
'description']
is not None:
63 print(testDef.options[
'description'], file=self.
fh)
68 classname = testDef.log[
'inifiles']
72 fullLog = testDef.logger.getLog(
None)
77 if 'stdout' in lg
and lg[
'stdout']
is not None:
78 stdout =
"\n".join(lg[
'stdout'])
81 if 'stderr' in lg
and lg[
'stderr']
is not None:
82 stderr =
"\n".join(lg[
'stderr'])
85 if 'time' in lg
and lg[
'time']
is not None:
89 tc = TestCase(lg[
'section'], classname, time, stdout, stderr)
93 if re.match(
"TestRun", lg[
'section']):
94 tc.add_failure_info(
"Test reported failure")
96 tc.add_error_info(
"Test error")
98 sys.exit(lg[
'section'] +
" is missing status!")
103 ts = TestSuite(jobid, testCases)
104 print(TestSuite.to_xml_string([ts]), file=self.
fh)
106 if cmds[
'filename']
is not None: