diff --git a/tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py b/tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py index b89379992..6277f0781 100644 --- a/tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py +++ b/tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py @@ -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 diff --git a/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py b/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py index e9a8e29b4..a77f3b579 100644 --- a/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py +++ b/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py @@ -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,7 +105,8 @@ class Search(object): if not replicate_config: break key = replicate_config.pop() - replicated_cases = _replicate_for_key(replicated_cases, key, case.case_info[key]) + 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 for case in replicated_cases: diff --git a/tools/ci/python_packages/ttfw_idf/__init__.py b/tools/ci/python_packages/ttfw_idf/__init__.py index d5d94956d..96d5f804d 100644 --- a/tools/ci/python_packages/ttfw_idf/__init__.py +++ b/tools/ci/python_packages/ttfw_idf/__init__.py @@ -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