From 343f3de559c636dcec941613dca91e4fff6547a3 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 13 Apr 2022 15:02:39 -0700 Subject: [PATCH] [lldb] Fix a bug in the decorator matching logic. This changes the decorator helper `_match_decorator_property` to consider `None` as the actual value as not a match. Using `None` for the pattern continues to be considered a match. I discovered the issue because marking a test as NO_DEBUG_INFO_TESTCASE will cause the call to `self.getDebugInfo()` to return `None` and incorrectly skip or XFAIL the corresponding test. I used the above scenario to create a test for the decorators. Differential revision: https://reviews.llvm.org/D123401 --- lldb/packages/Python/lldbsuite/test/decorators.py | 15 ++++++++++----- lldb/test/API/test_utils/TestDecorators.py | 13 +++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 lldb/test/API/test_utils/TestDecorators.py diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index c44c007..8f63602 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -73,18 +73,23 @@ def _check_expected_version(comparison, expected, actual): _re_pattern_type = type(re.compile('')) def _match_decorator_property(expected, actual): - if actual is None or expected is None: + if expected is None: return True + if actual is None : + return False + if isinstance(expected, no_match): return not _match_decorator_property(expected.item, actual) - elif isinstance(expected, (_re_pattern_type,) + six.string_types): + + if isinstance(expected, (_re_pattern_type,) + six.string_types): return re.search(expected, actual) is not None - elif hasattr(expected, "__iter__"): + + if hasattr(expected, "__iter__"): return any([x is not None and _match_decorator_property(x, actual) for x in expected]) - else: - return expected == actual + + return expected == actual def _compiler_supports(compiler, diff --git a/lldb/test/API/test_utils/TestDecorators.py b/lldb/test/API/test_utils/TestDecorators.py new file mode 100644 index 0000000..f536f42 --- /dev/null +++ b/lldb/test/API/test_utils/TestDecorators.py @@ -0,0 +1,13 @@ +from lldbsuite.test.lldbtest import Base +from lldbsuite.test.decorators import * + + +class TestDecorators(Base): + + mydir = Base.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + @expectedFailureAll(debug_info="dwarf") + def test_decorator_skip_no_debug_info(self): + """Test that specifying a debug info category works for a NO_DEBUG_INFO_TESTCASE""" + pass -- 2.7.4