Changeset View
Changeset View
Standalone View
Standalone View
lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
def ApplyDecoratorsToFunction(func, decorators): | def ApplyDecoratorsToFunction(func, decorators): | ||||
tmp = func | tmp = func | ||||
if type(decorators) == list: | if type(decorators) == list: | ||||
for decorator in decorators: | for decorator in decorators: | ||||
tmp = decorator(tmp) | tmp = decorator(tmp) | ||||
elif hasattr(decorators, '__call__'): | elif hasattr(decorators, '__call__'): | ||||
tmp = decorators(tmp) | tmp = decorators(tmp) | ||||
return tmp | return tmp | ||||
def MakeInlineTest(__file, __globals, decorators=None): | def MakeInlineTest(__file, __globals, decorators=None): | ||||
# Adjust the filename if it ends in .pyc. We want filenames to | # Adjust the filename if it ends in .pyc. We want filenames to | ||||
# reflect the source python file, not the compiled variant. | # reflect the source python file, not the compiled variant. | ||||
if __file is not None and __file.endswith(".pyc"): | if __file is not None and __file.endswith(".pyc"): | ||||
# Strip the trailing "c" | # Strip the trailing "c" | ||||
__file = __file[0:-1] | __file = __file[0:-1] | ||||
# Derive the test name from the current file name | # Derive the test name from the current file name | ||||
file_basename = os.path.basename(__file) | file_basename = os.path.basename(__file) | ||||
InlineTest.mydir = TestBase.compute_mydir(__file) | InlineTest.mydir = TestBase.compute_mydir(__file) | ||||
test_name, _ = os.path.splitext(file_basename) | test_name, _ = os.path.splitext(file_basename) | ||||
# Build the test case | # Build the test case | ||||
test = type(test_name, (InlineTest,), {'using_dsym': None}) | test = type(test_name, (InlineTest,), {'using_dsym': None}) | ||||
test.name = test_name | test.name = test_name | ||||
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] | |||||
if test_categories.is_supported_on_platform("dsym", target_platform): | |||||
test.test_with_dsym = ApplyDecoratorsToFunction(test._InlineTest__test_with_dsym, decorators) | test.test_with_dsym = ApplyDecoratorsToFunction(test._InlineTest__test_with_dsym, decorators) | ||||
if test_categories.is_supported_on_platform("dwarf", target_platform): | |||||
test.test_with_dwarf = ApplyDecoratorsToFunction(test._InlineTest__test_with_dwarf, decorators) | test.test_with_dwarf = ApplyDecoratorsToFunction(test._InlineTest__test_with_dwarf, decorators) | ||||
if test_categories.is_supported_on_platform("dwo", target_platform): | |||||
test.test_with_dwo = ApplyDecoratorsToFunction(test._InlineTest__test_with_dwo, decorators) | test.test_with_dwo = ApplyDecoratorsToFunction(test._InlineTest__test_with_dwo, decorators) | ||||
# Add the test case to the globals, and hide InlineTest | # Add the test case to the globals, and hide InlineTest | ||||
__globals.update({test_name : test}) | __globals.update({test_name : test}) | ||||
# Keep track of the original test filename so we report it | # Keep track of the original test filename so we report it | ||||
# correctly in test results. | # correctly in test results. | ||||
test.test_filename = __file | test.test_filename = __file | ||||
return test | return test | ||||