[Lldb-commits] [lldb] r255161 - enable timeout/exceptional exit support for xUnit formatter

Todd Fiala via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 9 14:02:32 PST 2015


Author: tfiala
Date: Wed Dec  9 16:02:31 2015
New Revision: 255161

URL: http://llvm.org/viewvc/llvm-project?rev=255161&view=rev
Log:
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.

Added:
    lldb/trunk/packages/Python/lldbsuite/test/issue_verification/disable.py   (with props)
    lldb/trunk/packages/Python/lldbsuite/test/issue_verification/enable.py   (with props)
Modified:
    lldb/trunk/packages/Python/lldbsuite/test/xunit_formatter.py

Added: lldb/trunk/packages/Python/lldbsuite/test/issue_verification/disable.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/issue_verification/disable.py?rev=255161&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/issue_verification/disable.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/issue_verification/disable.py Wed Dec  9 16:02:31 2015
@@ -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()

Propchange: lldb/trunk/packages/Python/lldbsuite/test/issue_verification/disable.py
------------------------------------------------------------------------------
    svn:executable = *

Added: lldb/trunk/packages/Python/lldbsuite/test/issue_verification/enable.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/issue_verification/enable.py?rev=255161&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/issue_verification/enable.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/issue_verification/enable.py Wed Dec  9 16:02:31 2015
@@ -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()

Propchange: lldb/trunk/packages/Python/lldbsuite/test/issue_verification/enable.py
------------------------------------------------------------------------------
    svn:executable = *

Modified: lldb/trunk/packages/Python/lldbsuite/test/xunit_formatter.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/xunit_formatter.py?rev=255161&r1=255160&r2=255161&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/xunit_formatter.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/xunit_formatter.py Wed Dec  9 16:02:31 2015
@@ -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.
@@ -259,6 +267,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):




More information about the lldb-commits mailing list