1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

oeqa/selftest/context.py: Change -t/-T args to be optional

Change the -t/-T args to be optional so that they can be used together
with the existing -r/-a/... args to run a more flexible filtering of
test tags.

(From OE-Core rev: 55ee27bb07113a45da18711b5509764f62be4d75)

Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Nathan Rossi
2019-09-07 12:55:06 +00:00
committed by Richard Purdie
parent db1cc0b533
commit 405d98e2bd
+18 -10
View File
@@ -61,12 +61,6 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
group.add_argument('-r', '--run-tests', required=False, action='store', group.add_argument('-r', '--run-tests', required=False, action='store',
nargs='+', dest="run_tests", default=None, nargs='+', dest="run_tests", default=None,
help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>') help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>')
group.add_argument('-t', '--run-only-tags', action='store',
nargs='+', dest="run_only_tags", default=None,
help='Run all (unhidden) tests which match any of the specified tags.')
group.add_argument('-T', '--run-exclude-tags', action='store',
nargs='+', dest="run_exclude_tags", default=None,
help='Run all (unhidden) tests excluding any that match any of the specified tags.')
group.add_argument('-m', '--list-modules', required=False, group.add_argument('-m', '--list-modules', required=False,
action="store_true", default=False, action="store_true", default=False,
@@ -84,6 +78,13 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
parser.add_argument('--machine', required=False, choices=['random', 'all'], parser.add_argument('--machine', required=False, choices=['random', 'all'],
help='Run tests on different machines (random/all).') help='Run tests on different machines (random/all).')
parser.add_argument('-t', '--select-tags', dest="select_tags",
nargs='*', default=None,
help='Filter all (unhidden) tests to any that match any of the specified tags.')
parser.add_argument('-T', '--exclude-tags', dest="exclude_tags",
nargs='*', default=None,
help='Exclude all (unhidden) tests that match any of the specified tags. (exclude applies before select)')
parser.set_defaults(func=self.run) parser.set_defaults(func=self.run)
def _get_available_machines(self): def _get_available_machines(self):
@@ -155,10 +156,17 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
copyfile(self.tc_kwargs['init']['config_paths']['bblayers'], copyfile(self.tc_kwargs['init']['config_paths']['bblayers'],
self.tc_kwargs['init']['config_paths']['bblayers_backup']) self.tc_kwargs['init']['config_paths']['bblayers_backup'])
if args.run_only_tags: def tag_filter(tags):
self.tc_kwargs['load']['tags_filter'] = lambda tags: not tags or not any(tag in args.run_only_tags for tag in tags) if args.exclude_tags:
if args.run_exclude_tags: if any(tag in args.exclude_tags for tag in tags):
self.tc_kwargs['load']['tags_filter'] = lambda tags: any(tag in args.run_exclude_tags for tag in tags) return True
if args.select_tags:
if not tags or not any(tag in args.select_tags for tag in tags):
return True
return False
if args.select_tags or args.exclude_tags:
self.tc_kwargs['load']['tags_filter'] = tag_filter
self.tc_kwargs['run']['skips'] = args.skips self.tc_kwargs['run']['skips'] = args.skips
self.tc_kwargs['run']['processes'] = args.processes self.tc_kwargs['run']['processes'] = args.processes