From f3e22ac3c7617590c8a832e0e7d98332e119fde3 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Fri, 10 Dec 2010 18:52:10 +0000 Subject: [PATCH] Add a '+a' command line option to the test driver to run only the Python API tests. Add an attribute __python_api_test__ (set to True) to the @python_api_test decorated test method to distinguish them from the lldb command line tests. llvm-svn: 121500 --- lldb/test/dotest.py | 5 +++-- lldb/test/lldbtest.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py index 970fc195d0c7..c48fce591508 100755 --- a/lldb/test/dotest.py +++ b/lldb/test/dotest.py @@ -46,11 +46,11 @@ class _WritelnDecorator(object): suite = unittest2.TestSuite() # By default, both command line and Python API tests are performed. -# See @python_api_test decorator in lldbtest.py. +# Use @python_api_test decorator, defined in lldbtest.py, to mark a test as +# a Python API test. dont_do_python_api_test = False # By default, both command line and Python API tests are performed. -# This does not work yet as the @lldb_command_test decorator is needed. just_do_python_api_test = False # The blacklist is optional (-b blacklistFile) and allows a central place to skip @@ -123,6 +123,7 @@ where options: -h : print this help message and exit (also --help) -a : don't do lldb Python API tests use @python_api_test to decorate a test case as lldb Python API test ++a : just do lldb Python API tests -b : read a blacklist file specified after this option -c : read a config file specified after this option (see also lldb-trunk/example/test/usage-config) diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index e6481c517042..da3cb842e062 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -236,6 +236,8 @@ def python_api_test(func): self.skipTest("Skip Python API tests") return func(self, *args, **kwargs) + # Mark this function as such to separate them from lldb command line tests. + wrapper.__python_api_test__ = True return wrapper class recording(StringIO.StringIO): @@ -477,6 +479,16 @@ class TestBase(unittest2.TestCase): elif classAndMethodName in lldb.blacklist: self.skipTest(lldb.blacklist.get(classAndMethodName)) + # Python API only test is decorated with @python_api_test, + # which also sets the "__python_api_test__" attribute of the + # function object to True. + if lldb.just_do_python_api_test: + testMethod = getattr(self, self._testMethodName) + if getattr(testMethod, "__python_api_test__", False): + pass + else: + self.skipTest("Skip lldb command line test") + if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): waitTime = 1.0