scripts/oe-selftest: add command line option to list test classes
While trying to discover what tests are available, I felt the need to be able to list all individual tests so I can run specific tests. This patch adds the "--list-classes" command line option that lists the unit test classes and methods available. (From OE-Core rev: f0ba400a398a172f9ebf953bb3a26e5d911a17d6) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
336d28c413
commit
7d73324af3
|
@ -66,6 +66,7 @@ def get_args_parser():
|
||||||
group.add_argument('--run-tests', required=False, action='store', nargs='*', dest="run_tests", default=None, help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>')
|
group.add_argument('--run-tests', required=False, action='store', nargs='*', dest="run_tests", default=None, help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>')
|
||||||
group.add_argument('--run-all-tests', required=False, action="store_true", dest="run_all_tests", default=False, help='Run all (unhidden) tests')
|
group.add_argument('--run-all-tests', required=False, action="store_true", dest="run_all_tests", default=False, help='Run all (unhidden) tests')
|
||||||
group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.')
|
group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.')
|
||||||
|
group.add_argument('--list-classes', required=False, action="store_true", dest="list_allclasses", default=False, help='List all available test classes.')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,6 +139,9 @@ def main():
|
||||||
parser = get_args_parser()
|
parser = get_args_parser()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.list_allclasses:
|
||||||
|
args.list_modules = True
|
||||||
|
|
||||||
if args.list_modules:
|
if args.list_modules:
|
||||||
log.info('Listing all available test modules:')
|
log.info('Listing all available test modules:')
|
||||||
testslist = get_tests(include_hidden=True)
|
testslist = get_tests(include_hidden=True)
|
||||||
|
@ -147,6 +151,22 @@ def main():
|
||||||
if module.startswith('_'):
|
if module.startswith('_'):
|
||||||
info = ' (hidden)'
|
info = ' (hidden)'
|
||||||
print module + info
|
print module + info
|
||||||
|
if args.list_allclasses:
|
||||||
|
try:
|
||||||
|
import importlib
|
||||||
|
modlib = importlib.import_module(test)
|
||||||
|
for v in vars(modlib):
|
||||||
|
t = vars(modlib)[v]
|
||||||
|
if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest:
|
||||||
|
print " --", v
|
||||||
|
for method in dir(t):
|
||||||
|
if method.startswith("test_"):
|
||||||
|
print " -- --", method
|
||||||
|
|
||||||
|
except (AttributeError, ImportError) as e:
|
||||||
|
print e
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if args.run_tests or args.run_all_tests:
|
if args.run_tests or args.run_all_tests:
|
||||||
if not preflight_check():
|
if not preflight_check():
|
||||||
|
|
Loading…
Reference in New Issue