From b3fc31dfed611afe5f1821810c67f422ca981355 Mon Sep 17 00:00:00 2001 From: Chris Matthews Date: Tue, 2 Dec 2014 22:19:21 +0000 Subject: Give lit a --xunit-xml-output option for saving results in xunit format --xunit-xml-output saves test results to disk in JUnit's xml format. This will allow Jenkins to report the details of a lit run. Based on a patch by David Chisnall. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223163 91177308-0d34-0410-b5e6-96231b3b80d8 (cherry picked from commit dcedd15f58e7b76c2ee61c8030799c209104229b) --- utils/lit/lit/Test.py | 15 +++++++++++++++ utils/lit/lit/main.py | 47 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/utils/lit/lit/Test.py b/utils/lit/lit/Test.py index e51bf12..2e0f478 100644 --- a/utils/lit/lit/Test.py +++ b/utils/lit/lit/Test.py @@ -1,4 +1,5 @@ import os +from xml.sax.saxutils import escape # Test result codes. @@ -194,3 +195,17 @@ class Test: return True return False + + + def getJUnitXML(self): + test_name = self.path_in_suite[-1] + test_path = self.path_in_suite[:-1] + + xml = "\n") + xunit_output_file.write("\n") + for suite_name, suite in by_suite.items(): + xunit_output_file.write("\n") + for result_test in suite['tests']: + xunit_output_file.write(result_test.getJUnitXML() + "\n") + xunit_output_file.write("\n") + xunit_output_file.write("") + xunit_output_file.close() + # If we encountered any additional errors, exit abnormally. if litConfig.numErrors: sys.stderr.write('\n%d error(s), exiting.\n' % litConfig.numErrors) -- cgit v1.1