summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMaciej Borzecki <maciej.borzecki@rndity.com>2016-11-10 13:18:37 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-15 15:19:55 +0000
commit59c8ae17420564a08490d7978560ef276c2b089a (patch)
tree2b19a2b9c7b99462792056c027149ca33f628779 /scripts
parent2eeed4838b7e1941b9dded9679c97d87e38e18d6 (diff)
downloadpoky-59c8ae17420564a08490d7978560ef276c2b089a.tar.gz
oe-selftest: fix handling of test cases without ID in --list-tests-by
Running `oe-selftest --list-tests-by module wic` will produce the following backtrace: Traceback (most recent call last): File "<snip>/poky/scripts/oe-selftest", line 668, in <module> ret = main() File "<snip>/poky/scripts/oe-selftest", line 486, in main list_testsuite_by(criteria, keyword) File "<snip>/poky/scripts/oe-selftest", line 340, in list_testsuite_by ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ]) TypeError: unorderable types: int() < NoneType() The root cause is that a test case does not necessarily have an ID assigned, hence its value is None. Since Python 3 does not allow comparison of heterogeneous types, TypeError is raised. (From OE-Core rev: 71c6790689e2cbd3c4e882335b3b03e635ad46ed) Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/oe-selftest13
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index d9ffd40e8c..c3215ea659 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -336,10 +336,15 @@ def list_testsuite_by(criteria, keyword):
336 # Get a testsuite based on 'keyword' 336 # Get a testsuite based on 'keyword'
337 # criteria: name, class, module, id, tag 337 # criteria: name, class, module, id, tag
338 # keyword: a list of tests, classes, modules, ids, tags 338 # keyword: a list of tests, classes, modules, ids, tags
339 339 def tc_key(t):
340 ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ]) 340 if t[0] is None:
341 341 return (0,) + t[1:]
342 print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module')) 342 return t
343 # tcid may be None if no ID was assigned, in which case sorted() will throw
344 # a TypeError as Python 3 does not allow comparison (<,<=,>=,>) of
345 # heterogeneous types, handle this by using a custom key generator
346 ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) \
347 for tc in get_testsuite_by(criteria, keyword) ], key=tc_key)
343 print('_' * 150) 348 print('_' * 150)
344 for t in ts: 349 for t in ts:
345 if isinstance(t[1], (tuple, list)): 350 if isinstance(t[1], (tuple, list)):