mirror of
https://github.com/intel/llvm.git
synced 2026-01-18 16:50:51 +08:00
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
This commit is contained in:
20
lldb/packages/Python/lldbsuite/test/issue_verification/disable.py
Executable file
20
lldb/packages/Python/lldbsuite/test/issue_verification/disable.py
Executable file
@@ -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()
|
||||
20
lldb/packages/Python/lldbsuite/test/issue_verification/enable.py
Executable file
20
lldb/packages/Python/lldbsuite/test/issue_verification/enable.py
Executable file
@@ -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()
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user