From 5618e73a459a9144c1fc988f5a72d093b7f587eb Mon Sep 17 00:00:00 2001 From: Chris Matthews Date: Tue, 2 Dec 2014 22:19:21 +0000 Subject: [PATCH] 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. llvm-svn: 223163 --- llvm/utils/lit/lit/Test.py | 15 +++++++++++++++ llvm/utils/lit/lit/main.py | 47 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py index e51bf12..2e0f478 100644 --- a/llvm/utils/lit/lit/Test.py +++ b/llvm/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) -- 2.7.4