diff options
author | Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 2016-03-18 15:18:09 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-20 23:12:29 +0000 |
commit | ee4f61b7e14a108d26eadc5e5b285e8d99c94545 (patch) | |
tree | b551ed9d27d65b71985039229dedf976f0a274bd /scripts/oe-selftest | |
parent | 068e89800140c796234503e801abc54c228e6da7 (diff) | |
download | poky-ee4f61b7e14a108d26eadc5e5b285e8d99c94545.tar.gz |
oe-selftest: Fixed --list-tests-by tag option
Commit 35be67951305950ba797dc2efddbc7d88fc0556a broke the
--list-tests-by tag option.
This patch fixes that.
Having a module in lib/oeqa/selftest named testmodule:
class TestClass(oeSelfTest):
@tag(feature='tag1')
def test_func1(self):
pass
@tag(feature=('tag1', 'tag2'))
def test_func2(self):
pass
@tag(feature=('tag2', 'tag3'))
def test_func3(self):
pass
@tag(feature=('tag1', 'tag2', 'tag3'))
def test_func4(self):
pass
$ oe-selftest --list-tests-by tag tag1
ID TAG(s) NAME CLASS MODULE
---- ---------------- ---------- --------- --------
tag1 test_func1 TestClass testmodule
tag1, tag2 test_func2 TestClass testmodule
tag1, tag2, tag3 test_func4 TestClass testmodule
______________________________
Filtering by: tag
Looking for: tag1
Total found: 3
$ oe-selftest --list-tests-by tag tag1 tag2
ID TAG(s) NAME CLASS MODULE
---- ---------------- ---------- --------- --------
tag1 test_func1 TestClass testmodule
tag1, tag2 test_func2 TestClass testmodule
tag1, tag2, tag3 test_func4 TestClass testmodule
tag2, tag3 test_func3 TestClass testmodule
______________________________
Filtering by: tag
Looking for: tag1, tag2
Total found: 4
$ oe-selftest --list-tests-by tag tag*
ID TAG(s) NAME CLASS MODULE
---- ---------------- ---------- --------- --------
tag1 test_func1 TestClass testmodule
tag1, tag2 test_func2 TestClass testmodule
tag1, tag2, tag3 test_func4 TestClass testmodule
tag2, tag3 test_func3 TestClass testmodule
______________________________
Filtering by: tag
Looking for: tag*
Total found: 4
(From OE-Core rev: 28c1cffacf341ad64a5b68d8a0176f92b49135c0)
Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-selftest')
-rwxr-xr-x | scripts/oe-selftest | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 9444244e02..d18348d1c6 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest | |||
@@ -32,6 +32,8 @@ import logging | |||
32 | import argparse | 32 | import argparse |
33 | import subprocess | 33 | import subprocess |
34 | import time as t | 34 | import time as t |
35 | import re | ||
36 | import fnmatch | ||
35 | 37 | ||
36 | sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') | 38 | sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') |
37 | import scriptpath | 39 | import scriptpath |
@@ -197,7 +199,7 @@ class Tc: | |||
197 | self.tcclass = tcclass | 199 | self.tcclass = tcclass |
198 | self.tcmodule = tcmodule | 200 | self.tcmodule = tcmodule |
199 | self.tcid = tcid | 201 | self.tcid = tcid |
200 | # A test case can have multiple tags (as list or as tuples) otherwise str suffice | 202 | # A test case can have multiple tags (as tuples) otherwise str will suffice |
201 | self.tctag = tctag | 203 | self.tctag = tctag |
202 | self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname]) | 204 | self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname]) |
203 | 205 | ||
@@ -243,19 +245,17 @@ def get_all_tests(): | |||
243 | testlist += get_tests_from_module(tmod) | 245 | testlist += get_tests_from_module(tmod) |
244 | return testlist | 246 | return testlist |
245 | 247 | ||
248 | |||
246 | def get_testsuite_by(criteria, keyword): | 249 | def get_testsuite_by(criteria, keyword): |
247 | # Get a testsuite based on 'keyword' | 250 | # Get a testsuite based on 'keyword' |
248 | # criteria: name, class, module, id, tag | 251 | # criteria: name, class, module, id, tag |
249 | # keyword: a list of tests, classes, modules, ids, tags | 252 | # keyword: a list of tests, classes, modules, ids, tags |
250 | 253 | ||
251 | import re | ||
252 | import fnmatch | ||
253 | |||
254 | ts = [] | 254 | ts = [] |
255 | all_tests = get_all_tests() | 255 | all_tests = get_all_tests() |
256 | 256 | ||
257 | def get_matches(values): | 257 | def get_matches(values): |
258 | # Get a items and return the ones that match with keyword(s) | 258 | # Get an item and return the ones that match with keyword(s) |
259 | # values: the list of items (names, modules, classes...) | 259 | # values: the list of items (names, modules, classes...) |
260 | result = [] | 260 | result = [] |
261 | remaining = values[:] | 261 | remaining = values[:] |
@@ -267,9 +267,9 @@ def get_testsuite_by(criteria, keyword): | |||
267 | else: | 267 | else: |
268 | # Wildcard matching | 268 | # Wildcard matching |
269 | pattern = re.compile(fnmatch.translate(r"%s" % key)) | 269 | pattern = re.compile(fnmatch.translate(r"%s" % key)) |
270 | added = [ x for x in remaining if pattern.match(x) ] | 270 | added = [x for x in remaining if pattern.match(x)] |
271 | result.extend(added) | 271 | result.extend(added) |
272 | remaining = [ x for x in remaining if not x in added ] | 272 | remaining = [x for x in remaining if x not in added] |
273 | 273 | ||
274 | return result | 274 | return result |
275 | 275 | ||
@@ -292,14 +292,23 @@ def get_testsuite_by(criteria, keyword): | |||
292 | elif criteria == 'tag': | 292 | elif criteria == 'tag': |
293 | values = set() | 293 | values = set() |
294 | for tc in all_tests: | 294 | for tc in all_tests: |
295 | # tc can have multiple tags (as list or tuple) otherwise as str | 295 | # tc can have multiple tags (as tuple) otherwise str will suffice |
296 | if isinstance(tc.tctag, (list, tuple)): | 296 | if isinstance(tc.tctag, tuple): |
297 | values |= { str(tag) for tag in tc.tctag } | 297 | values |= { str(tag) for tag in tc.tctag } |
298 | else: | 298 | else: |
299 | values.add(str(tc.tctag)) | 299 | values.add(str(tc.tctag)) |
300 | 300 | ||
301 | tags = get_matches(list(values)) | 301 | tags = get_matches(list(values)) |
302 | ts = [ tc for tc in all_tests if str(tc.tctag) in tags ] | 302 | |
303 | for tc in all_tests: | ||
304 | for tag in tags: | ||
305 | if isinstance(tc.tctag, tuple) and tag in tc.tctag: | ||
306 | ts.append(tc) | ||
307 | elif tag == tc.tctag: | ||
308 | ts.append(tc) | ||
309 | |||
310 | # Remove duplicates from the list | ||
311 | ts = list(set(ts)) | ||
303 | 312 | ||
304 | return ts | 313 | return ts |
305 | 314 | ||