From f687e98f005544a4a9c7dad38579f5f91573a6ed Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 24 Jul 2025 23:46:37 -0700 Subject: [PATCH 1/2] [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. --- .../Python/lldbsuite/test/lldbtest.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 63fadb59a82a1..9f2566ffe183e 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1775,16 +1775,20 @@ def no_reason(_): attrvalue, "__no_debug_info_test__", False ): # If any debug info categories were explicitly tagged, assume that list to be - # authoritative. If none were specified, try with all debug - # info formats. - all_dbginfo_categories = set( + # authoritative. If none were specified, try with all debug info formats. + test_method_categories = getattr(attrvalue, "categories", []) + dbginfo_categories = set(test_method_categories) & set( test_categories.debug_info_categories.keys() ) - categories = ( - set(getattr(attrvalue, "categories", [])) & all_dbginfo_categories - ) - if not categories: - categories = [ + if dbginfo_categories: + other_categories = [ + category + for category in test_method_categories + if category not in dbginfo_categories + ] + else: + other_categories = test_method_categories + dbginfo_categories = [ category for category, can_replicate in test_categories.debug_info_categories.items() if can_replicate @@ -1796,9 +1800,8 @@ def no_reason(_): skip_for_debug_info_cat_fn = getattr( attrvalue, "__skip_for_debug_info_cat_fn__", no_reason ) - for cat in categories: + for cat in dbginfo_categories: - @decorators.add_test_categories([cat]) @wraps(attrvalue) def test_method(self, attrvalue=attrvalue): return attrvalue(self) @@ -1806,6 +1809,7 @@ def test_method(self, attrvalue=attrvalue): method_name = attrname + "_" + cat test_method.__name__ = method_name test_method.debug_info = cat + test_method.categories = other_categories + [cat] xfail_reason = xfail_for_debug_info_cat_fn(cat) if xfail_reason: From 85f8b0bcaf7bfa64023e4084c1103c4fa4f08ff4 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 29 Jul 2025 13:21:34 -0700 Subject: [PATCH 2/2] fixup! Use the set difference operator to calculate 'other_categories' --- lldb/packages/Python/lldbsuite/test/lldbtest.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index e2478ae3f9dad..e9d3bad1a7e3f 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1779,18 +1779,13 @@ def no_reason(_): ): # If any debug info categories were explicitly tagged, assume that list to be # authoritative. If none were specified, try with all debug info formats. - test_method_categories = getattr(attrvalue, "categories", []) - dbginfo_categories = set(test_method_categories) & set( + test_method_categories = set(getattr(attrvalue, "categories", [])) + all_dbginfo_categories = set( test_categories.debug_info_categories.keys() ) - if dbginfo_categories: - other_categories = [ - category - for category in test_method_categories - if category not in dbginfo_categories - ] - else: - other_categories = test_method_categories + dbginfo_categories = test_method_categories & all_dbginfo_categories + other_categories = list(test_method_categories - all_dbginfo_categories) + if not dbginfo_categories: dbginfo_categories = [ category for category, can_replicate in test_categories.debug_info_categories.items()