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 @@ -15,7 +15,7 @@ mydir = TestBase.compute_mydir(__file__) - @skipUnlessArch(archs=re.compile('mips*')) + @skipUnlessArch(archs=[re.compile('mips*')]) def test(self): self.build() exe = os.path.join(os.getcwd(), "a.out") Index: packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -557,45 +557,21 @@ def debugserver_test(func): """Decorate the item as a debugserver test.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@debugserver_test can only be used to decorate a test method") - @wraps(func) - def wrapper(self, *args, **kwargs): - if configuration.dont_do_debugserver_test: - self.skipTest("debugserver tests") - return func(self, *args, **kwargs) - - # Mark this function as such to separate them from the regular tests. - wrapper.__debugserver_test__ = True - return wrapper + def should_skip_debugserver_tests(): + return (configuration.dont_do_debugserver_test, "debugserver tests") + return skipTestIfFn(should_skip_debugserver_tests) def llgs_test(func): """Decorate the item as a lldb-server test.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@llgs_test can only be used to decorate a test method") - @wraps(func) - def wrapper(self, *args, **kwargs): - if configuration.dont_do_llgs_test: - self.skipTest("llgs tests") - return func(self, *args, **kwargs) - - # Mark this function as such to separate them from the regular tests. - wrapper.__llgs_test__ = True - return wrapper + def should_skip_llgs_tests(): + return (configuration.dont_do_llgs_test, "llgs tests") + return skipTestIfFn(should_skip_llgs_tests) def not_remote_testsuite_ready(func): """Decorate the item as a test which is not ready yet for remote testsuite.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@not_remote_testsuite_ready can only be used to decorate a test method") - @wraps(func) - def wrapper(self, *args, **kwargs): - if lldb.remote_platform: - self.skipTest("not ready for remote testsuite") - return func(self, *args, **kwargs) - - # Mark this function as such to separate them from the regular tests. - wrapper.__not_ready_for_remote_testsuite_test__ = True - return wrapper + def is_remote(): + return (lldb.remote_platform, "Not ready for remote testsuite") + return skipTestIfFn(is_remote) def expectedFailure(expected_fn, bugnumber=None): def expectedFailure_impl(func): @@ -630,7 +606,16 @@ # are simple lists, namely oslist, compiler, and debug_info. def not_in(iterable): - return lambda x : x not in iterable + def check_no_items_match(x): + for item in iterable: + if isinstance(item, re._pattern_type): + if re.match(item, x): + return False + else: + if item == x: + return False + return True + return check_no_items_match def check_list_or_lambda(list_or_lambda, value): if six.callable(list_or_lambda): @@ -832,76 +817,47 @@ def skipIfRemote(func): """Decorate the item to skip tests if testing remotely.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipIfRemote can only be used to decorate a test method") - @wraps(func) - def wrapper(*args, **kwargs): - from unittest2 import case - if lldb.remote_platform: - self = args[0] - self.skipTest("skip on remote platform") - else: - func(*args, **kwargs) - return wrapper + def is_remote(): + return (lldb.remote_platform, "skip on remote platform") + return skipTestIfFn(is_remote) def skipUnlessListedRemote(remote_list=None): - def myImpl(func): - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipIfRemote can only be used to decorate a " - "test method") - - @wraps(func) - def wrapper(*args, **kwargs): - if remote_list and lldb.remote_platform: - self = args[0] - triple = self.dbg.GetSelectedPlatform().GetTriple() - for r in remote_list: - if r in triple: - func(*args, **kwargs) - return - self.skipTest("skip on remote platform %s" % str(triple)) - else: - func(*args, **kwargs) - return wrapper - - return myImpl + def is_remote_unlisted(self): + if remote_list and lldb.remote_platform: + triple = self.dbg.GetSelectedPlatform().GetTriple() + for r in remote_list: + if r in triple: + return (False, None) + return (True, "skipping because remote is not listed") + else: + return (True, "skipping because remote is not listed") + return skipTestIfFn(is_remote_unlisted) def skipIfRemoteDueToDeadlock(func): """Decorate the item to skip tests if testing remotely due to the test deadlocking.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipIfRemote can only be used to decorate a test method") - @wraps(func) - def wrapper(*args, **kwargs): - from unittest2 import case - if lldb.remote_platform: - self = args[0] - self.skipTest("skip on remote platform (deadlocks)") - else: - func(*args, **kwargs) - return wrapper + def is_remote(): + return (lldb.remote_platform, "skip on remote platform (deadlocks)") + return skipTestIfFn(is_remote) def skipIfNoSBHeaders(func): """Decorate the item to mark tests that should be skipped when LLDB is built with no SB API headers.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipIfNoSBHeaders can only be used to decorate a test method") - @wraps(func) - def wrapper(*args, **kwargs): - from unittest2 import case - self = args[0] + def are_sb_headers_missing(): if sys.platform.startswith("darwin"): header = os.path.join(os.environ["LLDB_LIB_DIR"], 'LLDB.framework', 'Versions','Current','Headers','LLDB.h') else: header = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API", "LLDB.h") platform = sys.platform if not os.path.exists(header): - self.skipTest("skip because LLDB.h header not found") + return (True, "skip because LLDB.h header not found") else: - func(*args, **kwargs) - return wrapper + return (False, None) + return skipTestIfFn(are_sb_headers_missing) def skipIfiOSSimulator(func): """Decorate the item to skip tests that should be skipped on the iOS Simulator.""" - return unittest2.skipIf(configuration.lldb_platform_name == 'ios-simulator', 'skip on the iOS Simulator')(func) + def is_ios_simulator(): + return (configuration.lldb_platform_name == 'ios-simulator', "skip on the iOS Simulator") + return skipTestIfFn(is_ios_simulator) def skipIfFreeBSD(func): """Decorate the item to skip tests that should be skipped on FreeBSD.""" @@ -944,36 +900,23 @@ def skipUnlessGoInstalled(func): """Decorate the item to skip tests when no Go compiler is available.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipIfGcc can only be used to decorate a test method") - @wraps(func) - def wrapper(*args, **kwargs): - from unittest2 import case - self = args[0] + def is_go_missing(self): compiler = self.getGoCompilerVersion() if not compiler: - self.skipTest("skipping because go compiler not found") + return (True, "skipping because go compiler not found") + match_version = re.search(r"(\d+\.\d+(\.\d+)?)", compiler) + if not match_version: + # Couldn't determine version. + return (True, "skipping because go version could not be parsed out of {}".format(compiler)) else: - # Ensure the version is the minimum version supported by - # the LLDB go support. - match_version = re.search(r"(\d+\.\d+(\.\d+)?)", compiler) - if not match_version: - # Couldn't determine version. - self.skipTest( - "skipping because go version could not be parsed " - "out of {}".format(compiler)) - else: - from distutils.version import StrictVersion - min_strict_version = StrictVersion("1.4.0") - compiler_strict_version = StrictVersion(match_version.group(1)) - if compiler_strict_version < min_strict_version: - self.skipTest( - "skipping because available go version ({}) does " - "not meet minimum required go version ({})".format( - compiler_strict_version, - min_strict_version)) - func(*args, **kwargs) - return wrapper + from distutils.version import StrictVersion + min_strict_version = StrictVersion("1.4.0") + compiler_strict_version = StrictVersion(match_version.group(1)) + if compiler_strict_version < min_strict_version: + return (True, "skipping because available version ({}) does not meet minimum required version ({})" + .format(compiler_strict_version, min_strict_version)) + return (False, None) + return skipTestIfFn(is_go_missing) def getPlatform(): """Returns the target platform which the tests are running on.""" @@ -1006,60 +949,37 @@ def skipIfHostIncompatibleWithRemote(func): """Decorate the item to skip tests if binaries built on this host are incompatible.""" - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipIfHostIncompatibleWithRemote can only be used to decorate a test method") - @wraps(func) - def wrapper(*args, **kwargs): - from unittest2 import case - self = args[0] + def is_host_incompatible_with_remote(self): host_arch = self.getLldbArchitecture() host_platform = getHostPlatform() target_arch = self.getArchitecture() target_platform = 'darwin' if self.platformIsDarwin() else self.getPlatform() if not (target_arch == 'x86_64' and host_arch == 'i386') and host_arch != target_arch: - self.skipTest("skipping because target %s is not compatible with host architecture %s" % (target_arch, host_arch)) + return (True, "skipping because target %s is not compatible with host architecture %s" % (target_arch, host_arch)) elif target_platform != host_platform: - self.skipTest("skipping because target is %s but host is %s" % (target_platform, host_platform)) - else: - func(*args, **kwargs) - return wrapper + return (True, "skipping because target is %s but host is %s" % (target_platform, host_platform)) + return (False, None) + return skipTestIfFn(is_host_incompatible_with_remote) def skipIfHostPlatform(oslist): """Decorate the item to skip tests if running on one of the listed host platforms.""" - return unittest2.skipIf(getHostPlatform() in oslist, - "skip on %s" % (", ".join(oslist))) + return skipIf(hostoslist=oslist) def skipUnlessHostPlatform(oslist): """Decorate the item to skip tests unless running on one of the listed host platforms.""" - return unittest2.skipUnless(getHostPlatform() in oslist, - "requires on of %s" % (", ".join(oslist))) + return skipIf(hostoslist=not_in(oslist)) def skipUnlessArch(archs): """Decorate the item to skip tests unless running on one of the listed architectures.""" - def myImpl(func): - if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipUnlessArch can only be used to decorate a test method") - - @wraps(func) - def wrapper(*args, **kwargs): - self = args[0] - if not matchArchitectures(archs, self.getArchitecture()): - self.skipTest("skipping for architecture %s" % (self.getArchitecture())) - else: - func(*args, **kwargs) - return wrapper - - return myImpl + return skipIf(archs=not_in(archs)) def skipIfPlatform(oslist): """Decorate the item to skip tests if running on one of the listed platforms.""" - return unittest2.skipIf(getPlatform() in oslist, - "skip on %s" % (", ".join(oslist))) + return skipIf(oslist=oslist) def skipUnlessPlatform(oslist): """Decorate the item to skip tests unless running on one of the listed platforms.""" - return unittest2.skipUnless(getPlatform() in oslist, - "requires on of %s" % (", ".join(oslist))) + return skipIf(oslist=not_in(oslist)) # provide a function to skip on defined oslist, compiler version, and archs # if none is specified for any argument, that argument won't be checked and thus means for all Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py =================================================================== --- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py +++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py @@ -834,7 +834,7 @@ post_handle_thread_id = int(post_handle_thread_id, 16) self.assertEqual(post_handle_thread_id, print_thread_id) - @unittest2.expectedFailure() + @expectedFailureAll @debugserver_test def test_Hc_then_Csignal_signals_correct_thread_launch_debugserver(self): self.init_debugserver_test()