[Lldb-commits] [lldb] [lldb][test] Fix running TestWithLimitDebugInfo.py on Windows (PR #150579)

via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 24 23:49:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)

<details>
<summary>Changes</summary>

When debug info categories were set for a test method with the `@<!-- -->add_test_categories` decorator, they were all added to its "categories" attribute. If some of these categories were not supported, `LLDBTestResult.startTest()` skipped all variants of the test method.

For example, the tests in `TestWithLimitDebugInfo.py` use the categories `dwarf` and `dwo`. However, since `dwo` is not supported on Windows, all the tests in this file were skipped, even though the tests for `dwarf` could be run.

---
Full diff: https://github.com/llvm/llvm-project/pull/150579.diff


2 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+16) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+1) 


``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index a5f58373ede75..72c79520773b4 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -431,6 +431,22 @@ def impl(func):
     return impl
 
 
+def remove_test_categories(remove_categories):
+    """Remove test categories from a TestCase method"""
+
+    def impl(func):
+        try:
+            if hasattr(func, "categories"):
+                updated = [c for c in func.categories if c not in remove_categories]
+                setattr(func, "categories", updated)
+        except AttributeError:
+            raise Exception("Cannot assign categories to inline tests.")
+
+        return func
+
+    return impl
+
+
 def no_debug_info_test(func):
     """Decorate the item as a test what don't use any debug info. If this annotation is specified
     then the test runner won't generate a separate test for each debug info format."""
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 63fadb59a82a1..48cef199737e2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1799,6 +1799,7 @@ def no_reason(_):
                 for cat in categories:
 
                     @decorators.add_test_categories([cat])
+                    @decorators.remove_test_categories(categories)
                     @wraps(attrvalue)
                     def test_method(self, attrvalue=attrvalue):
                         return attrvalue(self)

``````````

</details>


https://github.com/llvm/llvm-project/pull/150579


More information about the lldb-commits mailing list