[Lldb-commits] [PATCH] D71099: [lldb][test] Handle .categories lookup for inline tests.

Jordan Rupprecht via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 5 16:35:14 PST 2019


rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71099

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


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
         """
         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 @@
             else:
                 folder = os.path.dirname(folder)
                 continue
+        raise Exception("Did not find a .categories file, starting at: %s" % start_path)
 
 
     def getCategoriesForTest(self, test):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71099.232472.patch
Type: text/x-patch
Size: 1131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191206/2f99788c/attachment-0001.bin>


More information about the lldb-commits mailing list