[Lldb-commits] [lldb] 343f3de - [lldb] Fix a bug in the decorator matching logic.
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 13 15:07:38 PDT 2022
Author: Jonas Devlieghere
Date: 2022-04-13T15:07:33-07:00
New Revision: 343f3de559c636dcec941613dca91e4fff6547a3
URL: https://github.com/llvm/llvm-project/commit/343f3de559c636dcec941613dca91e4fff6547a3
DIFF: https://github.com/llvm/llvm-project/commit/343f3de559c636dcec941613dca91e4fff6547a3.diff
LOG: [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
Added:
lldb/test/API/test_utils/TestDecorators.py
Modified:
lldb/packages/Python/lldbsuite/test/decorators.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index c44c007a20fc2..8f636024abe91 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -73,18 +73,23 @@ def fn_neq(x, y): return x != y
_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 0000000000000..f536f4255656c
--- /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
More information about the lldb-commits
mailing list