Index: packages/Python/lldbsuite/test/decorators.py =================================================================== --- packages/Python/lldbsuite/test/decorators.py +++ packages/Python/lldbsuite/test/decorators.py @@ -25,6 +25,13 @@ class DecorateMode: Skip, Xfail = range(2) + +# You can use no_match to reverse the test of the conditional that is used to match keyword +# arguments in the skip / xfail decorators. If oslist=["windows", "linux"] skips windows +# and linux, oslist=no_match(["windows", "linux"]) skips *unless* windows or linux. +class no_match: + def __init__(self, item): + self.item = item def _check_expected_version(comparison, expected, actual): def fn_leq(x,y): return x <= y @@ -49,18 +56,19 @@ return op_lookup[comparison](LooseVersion(actual_str), LooseVersion(expected_str)) -def _check_list_or_lambda(list_or_lambda, value): - if six.callable(list_or_lambda): - return list_or_lambda(value) - elif isinstance(list_or_lambda, list): - for item in list_or_lambda: - if value in item: - return True - return False - elif isinstance(list_or_lambda, str): - return value is None or value in list_or_lambda +def _match_decorator_property(expected, actual): + if actual is None or expected is None: + return True + + if isinstance(expected, no_match): + return not _match_decorator_property(expected.item, actual) + elif isinstance(expected, (str, re._pattern_type)): + return re.search(expected, actual) is not None + elif hasattr(expected, "__iter__"): + result = any([x is not None and _match_decorator_property(x, actual) for x in expected]) + return result else: - return list_or_lambda is None or value is None or list_or_lambda == value + return expected == actual def expectedFailure(expected_fn, bugnumber=None): def expectedFailure_impl(func): @@ -131,15 +139,16 @@ swig_version=None, py_version=None, remote=None): def fn(self): - skip_for_os = _check_list_or_lambda(oslist, self.getPlatform()) - skip_for_hostos = _check_list_or_lambda(hostoslist, lldbplatformutil.getHostPlatform()) - skip_for_compiler = _check_list_or_lambda(self.getCompiler(), compiler) and self.expectedCompilerVersion(compiler_version) - skip_for_arch = _check_list_or_lambda(archs, self.getArchitecture()) - skip_for_debug_info = _check_list_or_lambda(debug_info, self.debug_info) - skip_for_triple = triple is None or re.match(triple, lldb.DBG.GetSelectedPlatform().GetTriple()) + skip_for_os = _match_decorator_property(oslist, self.getPlatform()) + skip_for_hostos = _match_decorator_property(hostoslist, lldbplatformutil.getHostPlatform()) + skip_for_compiler = _match_decorator_property(compiler, self.getCompiler()) and self.expectedCompilerVersion(compiler_version) + skip_for_arch = _match_decorator_property(archs, self.getArchitecture()) + skip_for_debug_info = _match_decorator_property(debug_info, self.debug_info) + skip_for_triple = _match_decorator_property(triple, lldb.DBG.GetSelectedPlatform().GetTriple()) + skip_for_remote = _match_decorator_property(remote, remote == (lldb.remote_platform is not None)) + skip_for_swig_version = (swig_version is None) or (not hasattr(lldb, 'swig_version')) or (_check_expected_version(swig_version[0], swig_version[1], lldb.swig_version)) skip_for_py_version = (py_version is None) or _check_expected_version(py_version[0], py_version[1], sys.version_info) - skip_for_remote = (remote is None) or (remote == (lldb.remote_platform is not None)) # For the test to be skipped, all specified (e.g. not None) parameters must be True. # An unspecified parameter means "any", so those are marked skip by default. And we skip @@ -283,12 +292,6 @@ return "Not ready for remote testsuite" if lldb.remote_platform else None return skipTestIfFn(is_remote)(func) -# You can also pass not_in(list) to reverse the sense of the test for the arguments that -# are simple lists, namely oslist, compiler, and debug_info. - -def not_in(iterable): - return lambda x : x not in iterable - def _match_architectures(archs, actual_arch): retype = type(re.compile('hello, world')) list_passes = isinstance(archs, list) and actual_arch in archs @@ -555,7 +558,7 @@ def skipUnlessHostPlatform(oslist): """Decorate the item to skip tests unless running on one of the listed host platforms.""" - return skipIf(hostoslist=not_in(oslist)) + return skipIf(hostoslist=no_match(oslist)) def skipUnlessArch(archs): """Decorate the item to skip tests unless running on one of the listed architectures.""" Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py @@ -16,7 +16,7 @@ mydir = TestBase.compute_mydir(__file__) - @skipUnlessArch(archs=re.compile('mips*')) + @skipIf(archs=no_match(re.compile('mips*'))) def test(self): self.build() exe = os.path.join(os.getcwd(), "a.out") Index: packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py @@ -14,7 +14,7 @@ mydir = TestBase.compute_mydir(__file__) - @skipIf(archs=not_in(["i386", "i686"])) + @skipIf(archs=no_match(["i386", "i686"])) @no_debug_info_test def test_asm_int_3(self): """Test that intrinsics like `__debugbreak();` and `asm {"int3"}` are treated like breakpoints.""" Index: packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py =================================================================== --- packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py +++ packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py @@ -7,7 +7,7 @@ mydir = TestBase.compute_mydir(__file__) - @skipIf(debug_info=not_in(["dwarf"])) + @skipIf(debug_info=no_match(["dwarf"])) def test_limit_debug_info(self): self.build()