Add an infrastructure to mark the Python APIs only test using a decorator.

Example:

    @python_api_test
    def test_evaluate_expression_python(self):
        """Test SBFrame.EvaluateExpression() API for evaluating an expression."""
    ...

The opposite of Python APIs only test is an lldb command line test, which sends
commands to the lldb command interpreter.  Add a '-a' option to the test driver
to skip Python API only tests.

Modify TestExprs.py to mark a test as @python_api_test and remove an @expectedFailure
decorator as the bug has been fixed.

llvm-svn: 121442
This commit is contained in:
Johnny Chen 2010-12-10 00:51:23 +00:00
parent aae7926e79
commit 7c7d936e48
3 changed files with 41 additions and 6 deletions

View File

@ -45,6 +45,14 @@ class _WritelnDecorator(object):
# The test suite.
suite = unittest2.TestSuite()
# By default, both command line and Python API tests are performed.
# See @python_api_test decorator in lldbtest.py.
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
# testclass's and/or testclass.testmethod's.
blacklist = None
@ -113,6 +121,8 @@ def usage():
Usage: dotest.py [option] [args]
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
-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)
@ -231,6 +241,8 @@ def parseOptionsAndInitTestdirs():
'-h/--help as the first option prints out usage info and exit the program.
"""
global dont_do_python_api_test
global just_do_python_api_test
global blacklist
global blacklistConfig
global configFile
@ -253,12 +265,21 @@ def parseOptionsAndInitTestdirs():
# Process possible trace and/or verbose flag, among other things.
index = 1
while index < len(sys.argv):
if not sys.argv[index].startswith('-'):
if sys.argv[index].startswith('-') or sys.argv[index].startswith('+'):
# We should continue processing...
pass
else:
# End of option processing.
break
if sys.argv[index].find('-h') != -1:
usage()
elif sys.argv[index].startswith('-a'):
dont_do_python_api_test = True
index += 1
elif sys.argv[index].startswith('+a'):
just_do_python_api_test = True
index += 1
elif sys.argv[index].startswith('-b'):
# Increment by 1 to fetch the blacklist file name option argument.
index += 1
@ -624,9 +645,13 @@ atexit.register(lambda: lldb.SBDebugger.Terminate())
# Create a singleton SBDebugger in the lldb namespace.
lldb.DBG = lldb.SBDebugger.Create()
# And put the blacklist in the lldb namespace, to be used by lldb.TestBase.
# Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
lldb.blacklist = blacklist
# Put dont/just_do_python_api_test in the lldb namespace, too.
lldb.dont_do_python_api_test = dont_do_python_api_test
lldb.just_do_python_api_test = just_do_python_api_test
# Turn on lldb loggings if necessary.
lldbLoggings()

View File

@ -78,7 +78,7 @@ class BasicExprCommandsTestCase(TestBase):
os.path.join(self.mydir, "a.out")])
# (const char *) $8 = 0x... "/Volumes/data/lldb/svn/trunk/test/expression_command/test/a.out"
@python_api_test
def test_evaluate_expression_python(self):
"""These SBFrame.EvaluateExpression() API."""
self.buildDefault()
@ -161,8 +161,6 @@ class BasicExprCommandsTestCase(TestBase):
startstr = "'Z'")
self.DebugSBValue(frame, val)
@unittest2.expectedFailure
# rdar://problem/8686536
# CommandInterpreter::HandleCommand is stripping \'s from input for WantsRawCommand commands
def test_expr_commands_can_handle_quotes(self):
@ -212,7 +210,9 @@ class BasicExprCommandsTestCase(TestBase):
# output:
self.runCmd(r'''command alias print_hi expression printf ("\n\tHi!\n")''')
# This fails currently.
self.runCmd('print_hi')
self.expect('print_hi',
substrs = ['(unsigned long) $',
'6'])
if __name__ == '__main__':

View File

@ -227,6 +227,16 @@ def pointer_size():
a_pointer = ctypes.c_void_p(0xffff)
return 8 * ctypes.sizeof(a_pointer)
from functools import wraps
def python_api_test(func):
"""Decorate the item as a Python API only test."""
@wraps(func)
def wrapper(self, *args, **kwargs):
if lldb.dont_do_python_api_test:
self.skipTest("Skip Python API tests")
return func(self, *args, **kwargs)
return wrapper
class recording(StringIO.StringIO):
"""