summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2015-12-09 22:02:31 +0000
committerTodd Fiala <todd.fiala@gmail.com>2015-12-09 22:02:31 +0000
commit5d96dc562935da64554bedef819ef2198bd711a6 (patch)
tree972f8a08f1afdbc17bef55cf83f01f8c7fac1226
parent63011e91d1b5716eeecf2483746f4cf8189c6723 (diff)
downloadbcm5719-llvm-5d96dc562935da64554bedef819ef2198bd711a6.tar.gz
bcm5719-llvm-5d96dc562935da64554bedef819ef2198bd711a6.zip
enable timeout/exceptional exit support for xUnit formatter
Also adds enable.py/disable.py script to simplify turning on and off the issue_verification tests helpful for testing a results formatter. llvm-svn: 255161
-rwxr-xr-xlldb/packages/Python/lldbsuite/test/issue_verification/disable.py20
-rwxr-xr-xlldb/packages/Python/lldbsuite/test/issue_verification/enable.py20
-rw-r--r--lldb/packages/Python/lldbsuite/test/xunit_formatter.py59
3 files changed, 97 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/issue_verification/disable.py b/lldb/packages/Python/lldbsuite/test/issue_verification/disable.py
new file mode 100755
index 00000000000..6d1f93e8b15
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/issue_verification/disable.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+"""Renames *.py files to *.py.park."""
+import os
+import sys
+
+
+def main():
+ """Drives the main script behavior."""
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ for filename in os.listdir(script_dir):
+ basename, extension = os.path.splitext(filename)
+ if basename.startswith("Test") and extension == '.py':
+ source_path = os.path.join(script_dir, filename)
+ dest_path = source_path + ".park"
+ sys.stdout.write("renaming {} to {}\n".format(
+ source_path, dest_path))
+ os.rename(source_path, dest_path)
+
+if __name__ == "__main__":
+ main()
diff --git a/lldb/packages/Python/lldbsuite/test/issue_verification/enable.py b/lldb/packages/Python/lldbsuite/test/issue_verification/enable.py
new file mode 100755
index 00000000000..eb19276de1f
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/issue_verification/enable.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+"""Renames *.py.park files to *.py."""
+import os
+import sys
+
+
+def main():
+ """Drives the main script behavior."""
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ for filename in os.listdir(script_dir):
+ basename, extension = os.path.splitext(filename)
+ if basename.startswith("Test") and extension == '.park':
+ source_path = os.path.join(script_dir, filename)
+ dest_path = os.path.join(script_dir, basename)
+ sys.stdout.write("renaming {} to {}\n".format(
+ source_path, dest_path))
+ os.rename(source_path, dest_path)
+
+if __name__ == "__main__":
+ main()
diff --git a/lldb/packages/Python/lldbsuite/test/xunit_formatter.py b/lldb/packages/Python/lldbsuite/test/xunit_formatter.py
index 5f7e507bf64..d792c1ff2d7 100644
--- a/lldb/packages/Python/lldbsuite/test/xunit_formatter.py
+++ b/lldb/packages/Python/lldbsuite/test/xunit_formatter.py
@@ -189,9 +189,17 @@ class XunitFormatter(ResultsFormatter):
EventBuilder.STATUS_EXPECTED_FAILURE:
self._handle_expected_failure,
EventBuilder.STATUS_UNEXPECTED_SUCCESS:
- self._handle_unexpected_success
+ self._handle_unexpected_success,
+ EventBuilder.STATUS_EXCEPTIONAL_EXIT:
+ self._handle_exceptional_exit,
+ EventBuilder.STATUS_TIMEOUT:
+ self._handle_timeout
}
+ RESULT_TYPES = set(
+ [EventBuilder.TYPE_TEST_RESULT,
+ EventBuilder.TYPE_JOB_RESULT])
+
def handle_event(self, test_event):
super(XunitFormatter, self).handle_event(test_event)
@@ -206,7 +214,7 @@ class XunitFormatter(ResultsFormatter):
test_event["test_class"],
test_event["test_name"],
test_event["event_time"])
- elif event_type == EventBuilder.TYPE_TEST_RESULT:
+ elif event_type in self.RESULT_TYPES:
self._process_test_result(test_event)
else:
# This is an unknown event.
@@ -260,6 +268,53 @@ class XunitFormatter(ResultsFormatter):
with self.lock:
self.elements["errors"].append(result)
+ def _handle_exceptional_exit(self, test_event):
+ """Handles an exceptional exit.
+ @param test_event the test method or job result event to handle.
+ """
+ if "test_name" in test_event:
+ name = test_event["test_name"]
+ else:
+ name = test_event.get("test_filename", "<unknown test/filename>")
+
+ message_text = "ERROR: {} ({}): {}".format(
+ test_event.get("exception_code", 0),
+ test_event.get("exception_description", ""),
+ name)
+ message = self._replace_invalid_xml(message_text)
+
+ result = self._common_add_testcase_entry(
+ test_event,
+ inner_content=(
+ '<error type={} message={}></error>'.format(
+ "exceptional_exit",
+ XunitFormatter._quote_attribute(message))
+ ))
+ with self.lock:
+ self.elements["errors"].append(result)
+
+ def _handle_timeout(self, test_event):
+ """Handles a test method or job timeout.
+ @param test_event the test method or job result event to handle.
+ """
+ if "test_name" in test_event:
+ name = test_event["test_name"]
+ else:
+ name = test_event.get("test_filename", "<unknown test/filename>")
+
+ message_text = "TIMEOUT: {}".format(name)
+ message = self._replace_invalid_xml(message_text)
+
+ result = self._common_add_testcase_entry(
+ test_event,
+ inner_content=(
+ '<error type={} message={}></error>'.format(
+ "timeout",
+ XunitFormatter._quote_attribute(message))
+ ))
+ with self.lock:
+ self.elements["errors"].append(result)
+
@staticmethod
def _ignore_based_on_regex_list(test_event, test_key, regex_list):
"""Returns whether to ignore a test event based on patterns.
OpenPOWER on IntegriCloud