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({