From 0817ac89c245ab7ade068b6a21e302a8815593d3 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Wed, 3 Dec 2014 18:17:15 +0000 Subject: [PATCH] Merging r223163: ------------------------------------------------------------------------ r223163 | cmatthews | 2014-12-02 14:19:21 -0800 (Tue, 02 Dec 2014) | 5 lines 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/branches/release_35@223250 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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 e51bf129776..2e0f478337b 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)