[Lldb-commits] [lldb] 9ba1512 - [lldb][test] NFC, re-use _getTestPath() function

Tatyana Krasnukha via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 10 05:32:50 PST 2020


Author: Tatyana Krasnukha
Date: 2020-01-10T16:31:03+03:00
New Revision: 9ba151274869c377921a09ba0bd635412da755ef

URL: https://github.com/llvm/llvm-project/commit/9ba151274869c377921a09ba0bd635412da755ef
DIFF: https://github.com/llvm/llvm-project/commit/9ba151274869c377921a09ba0bd635412da755ef.diff

LOG: [lldb][test] NFC, re-use _getTestPath() function

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/test_result.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py
index efa44b0e48d9..13500856e420 100644
--- a/lldb/packages/Python/lldbsuite/test/test_result.py
+++ b/lldb/packages/Python/lldbsuite/test/test_result.py
@@ -7,10 +7,7 @@
 and results of a single test run.
 """
 
-from __future__ import absolute_import
-
 # System modules
-import inspect
 import os
 
 # Third-party modules
@@ -102,22 +99,26 @@ def getDescription(self, test):
         else:
             return str(test)
 
-    @staticmethod
-    def _getFileBasedCategories(test):
+    def _getTestPath(self, test):
+        # Use test.test_filename if the test was created with
+        # lldbinline.MakeInlineTest().
+        if test is None:
+            return ""
+        elif hasattr(test, "test_filename"):
+            return test.test_filename
+        else:
+            import inspect
+            return inspect.getsourcefile(test.__class__)
+
+    def _getFileBasedCategories(self, test):
         """
         Returns the list of categories to which this test case belongs by
         collecting values of ".categories" files. We start at the folder the test is in
         and traverse the hierarchy upwards until the test-suite root directory.
         """
-        import inspect
-        import os.path
-        # Use test.test_filename if the test was created with
-        # lldbinline.MakeInlineTest().
-        if hasattr(test, 'test_filename'):
-            start_path = test.test_filename
-        else:
-            start_path = inspect.getfile(test.__class__)
+        start_path = self._getTestPath(test)
 
+        import os.path
         folder = os.path.dirname(start_path)
 
         from lldbsuite import lldb_test_root as test_root
@@ -198,14 +199,6 @@ def _isBuildError(self, err_tuple):
         exception = err_tuple[1]
         return isinstance(exception, build_exception.BuildError)
 
-    def _getTestPath(self, test):
-        if test is None:
-            return ""
-        elif hasattr(test, "test_filename"):
-            return test.test_filename
-        else:
-            return inspect.getsourcefile(test.__class__)
-
     def _saveBuildErrorTuple(self, test, err):
         # Adjust the error description so it prints the build command and build error
         # rather than an uninformative Python backtrace.


        


More information about the lldb-commits mailing list