diff options
author | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-08 00:26:53 +0000 |
---|---|---|
committer | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-08 00:26:53 +0000 |
commit | 5d10e417e97bfe7581c72460c46f83722ece6693 (patch) | |
tree | 765c31315c6f262949be75b0d128b9b947aabee6 /lldb/packages/Python/lldbsuite/test/dotest.py | |
parent | 37cf39df20825980adf55143005b553bb7e12047 (diff) | |
download | bcm5719-llvm-5d10e417e97bfe7581c72460c46f83722ece6693.tar.gz bcm5719-llvm-5d10e417e97bfe7581c72460c46f83722ece6693.zip |
DWIMy filterspecs for dotest.py
Summary:
dotest.py currently requires a filterspec to be of the
form `TestCase.test_method`. This patch makes it more
flexible, so you can pass `TestModule.TestCase.test_method`
or `TestModule.TestCase` or `TestCase.test_method` or just
`test_method`.
This makes it more convenient to just copy a test name
out of the terminal after running a bunch of tests and use
it as a filterspec.
Reviewers: JDevlieghere, jasonmolenda, labath
Reviewed By: JDevlieghere
Subscribers: jingham, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68545
llvm-svn: 373997
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/dotest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/dotest.py | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 04917185de2..652a02e5ed6 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -667,34 +667,42 @@ def visit_file(dir, name): # Thoroughly check the filterspec against the base module and admit # the (base, filterspec) combination only when it makes sense. - filterspec = None - for filterspec in configuration.filters: - # Optimistically set the flag to True. - filtered = True - module = __import__(base) - parts = filterspec.split('.') - obj = module + + def check(obj, parts): for part in parts: try: parent, obj = obj, getattr(obj, part) except AttributeError: # The filterspec has failed. - filtered = False - break - - # If filtered, we have a good filterspec. Add it. - if filtered: - # print("adding filter spec %s to module %s" % (filterspec, module)) - configuration.suite.addTests( - unittest2.defaultTestLoader.loadTestsFromName( - filterspec, module)) - continue + return False + return True + + module = __import__(base) + + def iter_filters(): + for filterspec in configuration.filters: + parts = filterspec.split('.') + if check(module, parts): + yield filterspec + elif parts[0] == base and len(parts) > 1 and check(module, parts[1:]): + yield '.'.join(parts[1:]) + else: + for key,value in module.__dict__.items(): + if check(value, parts): + yield key + '.' + filterspec + + filtered = False + for filterspec in iter_filters(): + filtered = True + print("adding filter spec %s to module %s" % (filterspec, repr(module))) + tests = unittest2.defaultTestLoader.loadTestsFromName(filterspec, module) + configuration.suite.addTests(tests) # Forgo this module if the (base, filterspec) combo is invalid if configuration.filters and not filtered: return - if not filterspec or not filtered: + if not filtered: # Add the entire file's worth of tests since we're not filtered. # Also the fail-over case when the filterspec branch # (base, filterspec) combo doesn't make sense. |