[Lldb-commits] [lldb] 03a242b - [lldb][test] Handle .categories lookup for inline tests.

Jordan Rupprecht via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 6 08:43:37 PST 2019


Author: Jordan Rupprecht
Date: 2019-12-06T08:36:23-08:00
New Revision: 03a242bd41ee49e17f8da96af9787d13e7ea2b93

URL: https://github.com/llvm/llvm-project/commit/03a242bd41ee49e17f8da96af9787d13e7ea2b93
DIFF: https://github.com/llvm/llvm-project/commit/03a242bd41ee49e17f8da96af9787d13e7ea2b93.diff

LOG: [lldb][test] Handle .categories lookup for inline tests.

Summary:
When creating a test with `lldbinline.MakeInlineTest()`, the reported `inspect.getfile(test.__class__)` is `lldbtest.pyc`, meaning any `.categories` file will be ineffective for those tests. Check for the test_filename first, which inline tests will set.

Additionally, raise an error with the starting dir if `.categories` is not found. This makes the problem more obvious when it occurs: when the test is separated from the test framework tree.

Reviewers: labath, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71099

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 8573b3b6be6f..7c924cfd6f2a 100644
--- a/lldb/packages/Python/lldbsuite/test/test_result.py
+++ b/lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@ def _getFileBasedCategories(test):
         """
         import inspect
         import os.path
-        folder = inspect.getfile(test.__class__)
-        folder = os.path.dirname(folder)
+        # 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__)
+
+        folder = os.path.dirname(start_path)
         while folder != '/':
             categories_file_name = os.path.join(folder, ".categories")
             if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@ def _getFileBasedCategories(test):
             else:
                 folder = os.path.dirname(folder)
                 continue
+        raise Exception("Did not find a .categories file, starting at: %s" % start_path)
 
 
     def getCategoriesForTest(self, test):


        


More information about the lldb-commits mailing list