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
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__"):
+ return any([x is not None and _match_decorator_property(x, actual) for x in expected])
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):
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, 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
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
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."""