Add list support for ttfw_idf test decorators. Only replicate supported keys

This commit is contained in:
Fu Hanxi 2020-04-30 11:49:51 +08:00
parent e553092d62
commit 5c92d36078
3 changed files with 26 additions and 5 deletions

View file

@ -44,6 +44,7 @@ import re
import json
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
@ -67,7 +68,7 @@ class Group(object):
self.case_list = [case]
self.filters = dict(zip(self.SORT_KEYS, [self._get_case_attr(case, x) for x in self.SORT_KEYS]))
# we use ci_job_match_keys to match CI job tags. It's a set of required tags.
self.ci_job_match_keys = set([self._get_case_attr(case, x) for x in self.CI_JOB_MATCH_KEYS])
self.ci_job_match_keys = self._get_match_keys(case)
@staticmethod
def _get_case_attr(case, attr):
@ -75,6 +76,16 @@ class Group(object):
# this method will do get attribute form cases
return case.case_info[attr]
def _get_match_keys(self, case):
keys = []
for attr in self.CI_JOB_MATCH_KEYS:
val = self._get_case_attr(case, attr)
if isinstance(val, list):
keys.extend(val)
else:
keys.append(val)
return set(keys)
def accept_new_case(self):
"""
check if allowed to add any case to this group

View file

@ -23,6 +23,7 @@ from . import load_source
class Search(object):
TEST_CASE_FILE_PATTERN = "*_test.py"
SUPPORT_REPLICATE_CASES_KEY = ['target']
@classmethod
def _search_cases_from_file(cls, file_name):
@ -104,6 +105,7 @@ class Search(object):
if not replicate_config:
break
key = replicate_config.pop()
if key in cls.SUPPORT_REPLICATE_CASES_KEY:
replicated_cases = _replicate_for_key(replicated_cases, key, case.case_info[key])
# mark the cases with targets not in ci_target

View file

@ -15,7 +15,7 @@ import functools
import os
import re
from typing import Union
from typing import Optional
from tiny_test_fw import TinyFW, Utility
from .IDFApp import IDFApp, Example, LoadableElfTestApp, UT, TestApp # noqa: export all Apps for users
@ -33,9 +33,17 @@ def format_case_id(chip, case_name):
return "{}.{}".format(chip, case_name)
def upper_list(text): # type: (Union[str, unicode, list]) -> list
if isinstance(text, basestring): # It's not working in python3
try:
string_type = basestring
except NameError:
string_type = str
def upper_list(text): # type: (Optional[string_type, list]) -> list
if isinstance(text, string_type):
res = [text.upper()]
elif text is None:
res = []
else:
res = [item.upper() for item in text]
return res