build component unit test apps

use idf_py_actions supported targets
This commit is contained in:
Fu Hanxi
2020-08-21 14:42:25 +08:00
parent 40d80b981a
commit e35328afd9
5 changed files with 106 additions and 83 deletions

View File

@@ -8,18 +8,16 @@ from collections import defaultdict
from find_apps import find_apps
from find_build_apps import BUILD_SYSTEMS, BUILD_SYSTEM_CMAKE
from ttfw_idf.IDFAssignTest import ExampleAssignTest, TestAppsAssignTest
VALID_TARGETS = [
'esp32',
'esp32s2',
]
from idf_py_actions.constants import SUPPORTED_TARGETS
TEST_LABELS = {
'example_test': 'BOT_LABEL_EXAMPLE_TEST',
'test_apps': 'BOT_LABEL_CUSTOM_TEST',
'component_ut': ['BOT_LABEL_UNIT_TEST', 'BOT_LABEL_UNIT_TEST_S2'],
}
BUILD_ALL_LABELS = [
'BOT_LABEL_BUILD',
'BOT_LABEL_BUILD_ALL_APPS',
'BOT_LABEL_REGULAR_TEST',
]
@@ -40,12 +38,17 @@ def _judge_build_or_not(action, build_all): # type: (str, bool) -> (bool, bool)
logging.info('Build all apps')
return True, True
if os.getenv(TEST_LABELS[action]):
logging.info('Build test cases apps')
return True, False
else:
logging.info('Skip all')
return False, False
labels = TEST_LABELS[action]
if not isinstance(labels, list):
labels = [labels]
for label in labels:
if os.getenv(label):
logging.info('Build test cases apps')
return True, False
else:
logging.info('Skip all')
return False, False
def output_json(apps_dict_list, target, build_system, output_dir):
@@ -59,8 +62,8 @@ def main():
parser.add_argument('test_type',
choices=TEST_LABELS.keys(),
help='Scan test type')
parser.add_argument('paths',
nargs='+',
parser.add_argument('-p', '--paths', nargs='+',
required=True,
help='One or more app paths')
parser.add_argument('-b', '--build-system',
choices=BUILD_SYSTEMS.keys(),
@@ -90,15 +93,17 @@ def main():
raise e
if (not build_standalone_apps) and (not build_test_case_apps):
for target in VALID_TARGETS:
for target in SUPPORTED_TARGETS:
output_json([], target, args.build_system, args.output_path)
SystemExit(0)
paths = set([os.path.join(os.getenv('IDF_PATH'), path) if not os.path.isabs(path) else path for path in args.paths])
test_cases = []
for path in set(args.paths):
for path in paths:
if args.test_type == 'example_test':
assign = ExampleAssignTest(path, args.ci_config_file)
elif args.test_type == 'test_apps':
elif args.test_type in ['test_apps', 'component_ut']:
assign = TestAppsAssignTest(path, args.ci_config_file)
else:
raise SystemExit(1) # which is impossible
@@ -123,7 +128,7 @@ def main():
build_system_class = BUILD_SYSTEMS[build_system]
if build_test_case_apps:
for target in VALID_TARGETS:
for target in SUPPORTED_TARGETS:
target_dict = scan_info_dict[target]
test_case_apps = target_dict['test_case_apps'] = set()
for case in test_cases:
@@ -134,21 +139,21 @@ def main():
test_case_apps.update(find_apps(build_system_class, app_dir, True, default_exclude, target.lower()))
exclude_apps.append(app_dir)
else:
for target in VALID_TARGETS:
for target in SUPPORTED_TARGETS:
scan_info_dict[target]['test_case_apps'] = set()
if build_standalone_apps:
for target in VALID_TARGETS:
for target in SUPPORTED_TARGETS:
target_dict = scan_info_dict[target]
standalone_apps = target_dict['standalone_apps'] = set()
for path in args.paths:
for path in paths:
standalone_apps.update(find_apps(build_system_class, path, True, exclude_apps, target.lower()))
else:
for target in VALID_TARGETS:
for target in SUPPORTED_TARGETS:
scan_info_dict[target]['standalone_apps'] = set()
test_case_apps_preserve_default = True if build_system == 'cmake' else False
for target in VALID_TARGETS:
for target in SUPPORTED_TARGETS:
apps = []
for app_dir in scan_info_dict[target]['test_case_apps']:
apps.append({

View File

@@ -17,6 +17,8 @@ except ImportError:
import gitlab_api
from tiny_test_fw.Utility import CIAssignTest
from idf_py_actions.constants import SUPPORTED_TARGETS
IDF_PATH_FROM_ENV = os.getenv("IDF_PATH")
@@ -35,6 +37,9 @@ class IDFCaseGroup(CIAssignTest.Group):
class IDFAssignTest(CIAssignTest.AssignTest):
def __init__(self, test_case_path, ci_config_file, case_group=IDFCaseGroup):
super(IDFAssignTest, self).__init__(test_case_path, ci_config_file, case_group)
def format_build_log_path(self, parallel_num):
return "{}/list_job_{}.json".format(self.case_group.LOCAL_BUILD_DIR, parallel_num)
@@ -67,12 +72,6 @@ class IDFAssignTest(CIAssignTest.AssignTest):
json.dump(artifact_index_list, f)
SUPPORTED_TARGETS = [
'esp32',
'esp32s2',
]
class ExampleGroup(IDFCaseGroup):
SORT_KEYS = CI_JOB_MATCH_KEYS = ["env_tag", "target"]
@@ -210,22 +209,29 @@ class UnitTestGroup(IDFCaseGroup):
class ExampleAssignTest(IDFAssignTest):
CI_TEST_JOB_PATTERN = re.compile(r'^example_test_.+')
def __init__(self, est_case_path, ci_config_file):
super(ExampleAssignTest, self).__init__(est_case_path, ci_config_file, case_group=ExampleGroup)
def __init__(self, test_case_path, ci_config_file):
super(ExampleAssignTest, self).__init__(test_case_path, ci_config_file, case_group=ExampleGroup)
class TestAppsAssignTest(IDFAssignTest):
CI_TEST_JOB_PATTERN = re.compile(r'^test_app_test_.+')
def __init__(self, est_case_path, ci_config_file):
super(TestAppsAssignTest, self).__init__(est_case_path, ci_config_file, case_group=TestAppsGroup)
def __init__(self, test_case_path, ci_config_file):
super(TestAppsAssignTest, self).__init__(test_case_path, ci_config_file, case_group=TestAppsGroup)
class ComponentUTAssignTest(IDFAssignTest):
CI_TEST_JOB_PATTERN = re.compile(r'^component_ut_test_.+')
def __init__(self, test_case_path, ci_config_file):
super(ComponentUTAssignTest, self).__init__(test_case_path, ci_config_file, case_group=ComponentUTGroup)
class UnitTestAssignTest(IDFAssignTest):
CI_TEST_JOB_PATTERN = re.compile(r'^UT_.+')
def __init__(self, est_case_path, ci_config_file):
super(UnitTestAssignTest, self).__init__(est_case_path, ci_config_file, case_group=UnitTestGroup)
def __init__(self, test_case_path, ci_config_file):
super(UnitTestAssignTest, self).__init__(test_case_path, ci_config_file, case_group=UnitTestGroup)
def search_cases(self, case_filter=None):
"""