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

Igor Kudrin via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 24 23:51:05 PDT 2025


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

>From a302c52a378ca5aed5092dbc29ba75447466a66c Mon Sep 17 00:00:00 2001
From: Igor Kudrin <ikudrin at accesssoftek.com>
Date: Thu, 24 Jul 2025 23:46:37 -0700
Subject: [PATCH] [lldb][test] Fix running TestWithLimitDebugInfo.py on Windows

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.
---
 .../packages/Python/lldbsuite/test/decorators.py | 16 ++++++++++++++++
 lldb/packages/Python/lldbsuite/test/lldbtest.py  |  1 +
 2 files changed, 17 insertions(+)

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)



More information about the lldb-commits mailing list