[Lldb-commits] [PATCH] D19215: normalize test file extension for test filenames

Todd Fiala via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 18 10:02:42 PDT 2016


tfiala updated this revision to Diff 54078.
tfiala added a comment.

Change inspect.getfile() => inspect.getsourcefile().


http://reviews.llvm.org/D19215

Files:
  packages/Python/lldbsuite/test/result_formatter.py

Index: packages/Python/lldbsuite/test/result_formatter.py
===================================================================
--- packages/Python/lldbsuite/test/result_formatter.py
+++ packages/Python/lldbsuite/test/result_formatter.py
@@ -64,7 +64,7 @@
     def create_socket(port):
         """Creates a socket to the localhost on the given port.
 
-        @param port the port number of the listenering port on
+        @param port the port number of the listening port on
         the localhost.
 
         @return (socket object, socket closing function)
@@ -243,6 +243,15 @@
         return event
 
     @staticmethod
+    def _normalize_test_filename(test_filename):
+        # Convert .pyc ending to .py.
+        if test_filename is not None and test_filename.endswith(".pyc"):
+            raise Exception("filename ends in .pyc: {}".format(test_filename))
+            return test_filename[0:-1]
+        else:
+            return test_filename
+
+    @staticmethod
     def _event_dictionary_common(test, event_type):
         """Returns an event dictionary setup with values for the given event type.
 
@@ -257,9 +266,9 @@
         # Determine the filename for the test case.  If there is an attribute
         # for it, use it.  Otherwise, determine from the TestCase class path.
         if hasattr(test, "test_filename"):
-            test_filename = test.test_filename
+            test_filename = EventBuilder._normalize_test_filename(test.test_filename)
         else:
-            test_filename = inspect.getsourcefile(test.__class__)
+            test_filename = EventBuilder._normalize_test_filename(inspect.getsourcefile(test.__class__))
 
         event = EventBuilder.bare_event(event_type)
         event.update({
@@ -498,7 +507,7 @@
         if exception_description is not None:
             event["exception_description"] = exception_description
         if test_filename is not None:
-            event["test_filename"] = test_filename
+            event["test_filename"] = EventBuilder._normalize_test_filename(test_filename)
         if command_line is not None:
             event["command_line"] = command_line
         return event
@@ -522,7 +531,7 @@
         if worker_index is not None:
             event["worker_index"] = int(worker_index)
         if test_filename is not None:
-            event["test_filename"] = test_filename
+            event["test_filename"] = EventBuilder._normalize_test_filename(test_filename)
         if command_line is not None:
             event["command_line"] = command_line
         return event


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19215.54078.patch
Type: text/x-patch
Size: 2573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160418/df758a38/attachment.bin>


More information about the lldb-commits mailing list