summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/context.py')
-rw-r--r--meta/lib/oeqa/selftest/context.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index 47de08e3f2..3126ada716 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -61,12 +61,6 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
61 group.add_argument('-r', '--run-tests', required=False, action='store', 61 group.add_argument('-r', '--run-tests', required=False, action='store',
62 nargs='+', dest="run_tests", default=None, 62 nargs='+', dest="run_tests", default=None,
63 help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>') 63 help='Select what tests to run (modules, classes or test methods). Format should be: <module>.<class>.<test_method>')
64 group.add_argument('-t', '--run-only-tags', action='store',
65 nargs='+', dest="run_only_tags", default=None,
66 help='Run all (unhidden) tests which match any of the specified tags.')
67 group.add_argument('-T', '--run-exclude-tags', action='store',
68 nargs='+', dest="run_exclude_tags", default=None,
69 help='Run all (unhidden) tests excluding any that match any of the specified tags.')
70 64
71 group.add_argument('-m', '--list-modules', required=False, 65 group.add_argument('-m', '--list-modules', required=False,
72 action="store_true", default=False, 66 action="store_true", default=False,
@@ -83,7 +77,14 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
83 77
84 parser.add_argument('--machine', required=False, choices=['random', 'all'], 78 parser.add_argument('--machine', required=False, choices=['random', 'all'],
85 help='Run tests on different machines (random/all).') 79 help='Run tests on different machines (random/all).')
86 80
81 parser.add_argument('-t', '--select-tags', dest="select_tags",
82 nargs='*', default=None,
83 help='Filter all (unhidden) tests to any that match any of the specified tags.')
84 parser.add_argument('-T', '--exclude-tags', dest="exclude_tags",
85 nargs='*', default=None,
86 help='Exclude all (unhidden) tests that match any of the specified tags. (exclude applies before select)')
87
87 parser.set_defaults(func=self.run) 88 parser.set_defaults(func=self.run)
88 89
89 def _get_available_machines(self): 90 def _get_available_machines(self):
@@ -155,10 +156,17 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
155 copyfile(self.tc_kwargs['init']['config_paths']['bblayers'], 156 copyfile(self.tc_kwargs['init']['config_paths']['bblayers'],
156 self.tc_kwargs['init']['config_paths']['bblayers_backup']) 157 self.tc_kwargs['init']['config_paths']['bblayers_backup'])
157 158
158 if args.run_only_tags: 159 def tag_filter(tags):
159 self.tc_kwargs['load']['tags_filter'] = lambda tags: not tags or not any(tag in args.run_only_tags for tag in tags) 160 if args.exclude_tags:
160 if args.run_exclude_tags: 161 if any(tag in args.exclude_tags for tag in tags):
161 self.tc_kwargs['load']['tags_filter'] = lambda tags: any(tag in args.run_exclude_tags for tag in tags) 162 return True
163 if args.select_tags:
164 if not tags or not any(tag in args.select_tags for tag in tags):
165 return True
166 return False
167
168 if args.select_tags or args.exclude_tags:
169 self.tc_kwargs['load']['tags_filter'] = tag_filter
162 170
163 self.tc_kwargs['run']['skips'] = args.skips 171 self.tc_kwargs['run']['skips'] = args.skips
164 self.tc_kwargs['run']['processes'] = args.processes 172 self.tc_kwargs['run']['processes'] = args.processes