summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/decorator
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2019-09-03 16:56:41 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-09-07 21:56:43 +0100
commitc3625e141dfbb6c8b8bfa3ff05e0e87f215bf606 (patch)
tree5c2e6dbfea3d050d7929234c4a880e923795a066 /meta/lib/oeqa/core/decorator
parent1220faf6659e404f6aa2c3155eb8840ac361c2b2 (diff)
downloadpoky-c3625e141dfbb6c8b8bfa3ff05e0e87f215bf606.tar.gz
oeqa/core: Rework OETestTag and remove unused OETestFilter
Rework OETestTag so that it does not rely on the existing decorator code base and instead inserts the tags into an attribute on the decorated target (e.g. class/type or method). This allows the use of OETestTag on classes and method. In order to filter tagged tests rework the loaders filtering code, removing the generic-ness (with validation and attributes/etc.) and replace it with a "tags_filter" parameter which is a function that filters a test based on the tags it has. This allows the loader user to filter on tags in more specific ways (e.g. include all untagged tests and any tests tagged with foo). Plumb all this through the context code and testing code. Update the associated tests to pass correctly with the changes. (From OE-Core rev: b8a4a4c2de68110d74607cb9807c9e741ca9441c) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/core/decorator')
-rw-r--r--meta/lib/oeqa/core/decorator/__init__.py20
-rw-r--r--meta/lib/oeqa/core/decorator/oetag.py27
2 files changed, 12 insertions, 35 deletions
diff --git a/meta/lib/oeqa/core/decorator/__init__.py b/meta/lib/oeqa/core/decorator/__init__.py
index 923b218266..1a5ac40134 100644
--- a/meta/lib/oeqa/core/decorator/__init__.py
+++ b/meta/lib/oeqa/core/decorator/__init__.py
@@ -6,6 +6,7 @@
6 6
7from functools import wraps 7from functools import wraps
8from abc import abstractmethod, ABCMeta 8from abc import abstractmethod, ABCMeta
9from oeqa.core.utils.misc import strToList
9 10
10decoratorClasses = set() 11decoratorClasses = set()
11 12
@@ -63,12 +64,15 @@ class OETestDiscover(OETestDecorator):
63 def discover(registry): 64 def discover(registry):
64 return registry['cases'] 65 return registry['cases']
65 66
66class OETestFilter(OETestDecorator): 67def OETestTag(*tags):
68 expandedtags = []
69 for tag in tags:
70 expandedtags += strToList(tag)
71 def decorator(item):
72 if hasattr(item, "__oeqa_testtags"):
73 item.__oeqa_testtags += expandedtags
74 else:
75 item.__oeqa_testtags = expandedtags
76 return item
77 return decorator
67 78
68 # OETestLoader call it while loading the tests
69 # in loadTestsFromTestCase method, it needs to
70 # return a bool, True if needs to be filtered.
71 # This method must consume the filter used.
72 @abstractmethod
73 def filtrate(self, filters):
74 return False
diff --git a/meta/lib/oeqa/core/decorator/oetag.py b/meta/lib/oeqa/core/decorator/oetag.py
deleted file mode 100644
index 8c31138dac..0000000000
--- a/meta/lib/oeqa/core/decorator/oetag.py
+++ /dev/null
@@ -1,27 +0,0 @@
1#
2# Copyright (C) 2016 Intel Corporation
3#
4# SPDX-License-Identifier: MIT
5#
6
7from . import OETestFilter, registerDecorator
8from oeqa.core.utils.misc import strToList
9
10def _tagFilter(tags, filters):
11 return False if set(tags) & set(filters) else True
12
13@registerDecorator
14class OETestTag(OETestFilter):
15 attrs = ('oetag',)
16
17 def bind(self, registry, case):
18 super(OETestTag, self).bind(registry, case)
19 self.oetag = strToList(self.oetag, 'oetag')
20
21 def filtrate(self, filters):
22 if filters.get('oetag'):
23 filterx = strToList(filters['oetag'], 'oetag')
24 del filters['oetag']
25 if _tagFilter(self.oetag, filterx):
26 return True
27 return False