mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
ci: support keyword nightly_run
in ttfw_idf decorator
This commit is contained in:
committed by
Aleksei Apaseev
parent
603be06120
commit
1b0fe85245
@ -6,6 +6,7 @@ import errno
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ except ImportError:
|
|||||||
SUPPORTED_TARGETS = []
|
SUPPORTED_TARGETS = []
|
||||||
PREVIEW_TARGETS = []
|
PREVIEW_TARGETS = []
|
||||||
|
|
||||||
IDF_PATH_FROM_ENV = os.getenv('IDF_PATH')
|
IDF_PATH_FROM_ENV = os.getenv('IDF_PATH', '')
|
||||||
|
|
||||||
|
|
||||||
class IDFCaseGroup(CIAssignTest.Group):
|
class IDFCaseGroup(CIAssignTest.Group):
|
||||||
@ -41,6 +42,13 @@ class IDFCaseGroup(CIAssignTest.Group):
|
|||||||
|
|
||||||
|
|
||||||
class IDFAssignTest(CIAssignTest.AssignTest):
|
class IDFAssignTest(CIAssignTest.AssignTest):
|
||||||
|
DEFAULT_FILTER = {
|
||||||
|
'category': 'function',
|
||||||
|
'ignore': False,
|
||||||
|
'supported_in_ci': True,
|
||||||
|
'nightly_run': False,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, test_case_path, ci_config_file, case_group=IDFCaseGroup):
|
def __init__(self, test_case_path, ci_config_file, case_group=IDFCaseGroup):
|
||||||
super(IDFAssignTest, self).__init__(test_case_path, ci_config_file, case_group)
|
super(IDFAssignTest, self).__init__(test_case_path, ci_config_file, case_group)
|
||||||
|
|
||||||
@ -75,6 +83,12 @@ class IDFAssignTest(CIAssignTest.AssignTest):
|
|||||||
with open(artifact_index_file, 'w') as f:
|
with open(artifact_index_file, 'w') as f:
|
||||||
json.dump(artifact_index_list, f)
|
json.dump(artifact_index_list, f)
|
||||||
|
|
||||||
|
def search_cases(self, case_filter=None):
|
||||||
|
_filter = deepcopy(case_filter) if case_filter else {}
|
||||||
|
if 'NIGHTLY_RUN' in os.environ:
|
||||||
|
_filter.update({'nightly_run': True})
|
||||||
|
return super().search_cases(_filter)
|
||||||
|
|
||||||
|
|
||||||
class ExampleGroup(IDFCaseGroup):
|
class ExampleGroup(IDFCaseGroup):
|
||||||
SORT_KEYS = CI_JOB_MATCH_KEYS = ['env_tag', 'target']
|
SORT_KEYS = CI_JOB_MATCH_KEYS = ['env_tag', 'target']
|
||||||
@ -315,7 +329,8 @@ if __name__ == '__main__':
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('case_group', choices=['example_test', 'custom_test', 'unit_test', 'component_ut'])
|
parser.add_argument('case_group', choices=['example_test', 'custom_test', 'unit_test', 'component_ut'])
|
||||||
parser.add_argument('test_case_paths', nargs='+', help='test case folder or file')
|
parser.add_argument('test_case_paths', nargs='+', help='test case folder or file')
|
||||||
parser.add_argument('-c', '--config', help='gitlab ci config file')
|
parser.add_argument('-c', '--config', default=os.path.join(IDF_PATH_FROM_ENV, '.gitlab', 'ci', 'target-test.yml'),
|
||||||
|
help='gitlab ci config file')
|
||||||
parser.add_argument('-o', '--output', help='output path of config files')
|
parser.add_argument('-o', '--output', help='output path of config files')
|
||||||
parser.add_argument('--pipeline_id', '-p', type=int, default=None, help='pipeline_id')
|
parser.add_argument('--pipeline_id', '-p', type=int, default=None, help='pipeline_id')
|
||||||
parser.add_argument('--test-case-file-pattern', help='file name pattern used to find Python test case files')
|
parser.add_argument('--test-case-file-pattern', help='file name pattern used to find Python test case files')
|
||||||
@ -323,7 +338,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
SUPPORTED_TARGETS.extend(PREVIEW_TARGETS)
|
SUPPORTED_TARGETS.extend(PREVIEW_TARGETS)
|
||||||
|
|
||||||
test_case_paths = [os.path.join(IDF_PATH_FROM_ENV, path) if not os.path.isabs(path) else path for path in args.test_case_paths] # type: ignore
|
test_case_paths = [os.path.join(IDF_PATH_FROM_ENV, path) if not os.path.isabs(path) else path for path in
|
||||||
|
args.test_case_paths] # type: ignore
|
||||||
args_list = [test_case_paths, args.config]
|
args_list = [test_case_paths, args.config]
|
||||||
if args.case_group == 'example_test':
|
if args.case_group == 'example_test':
|
||||||
assigner = ExampleAssignTest(*args_list)
|
assigner = ExampleAssignTest(*args_list)
|
||||||
|
@ -118,7 +118,7 @@ def ci_target_check(func):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, **kwargs):
|
def test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, nightly_run, **kwargs):
|
||||||
target = upper_list_or_str(target)
|
target = upper_list_or_str(target)
|
||||||
test_target = local_test_check(target)
|
test_target = local_test_check(target)
|
||||||
if 'additional_duts' in kwargs:
|
if 'additional_duts' in kwargs:
|
||||||
@ -130,7 +130,7 @@ def test_func_generator(func, app, target, ci_target, module, execution_time, le
|
|||||||
original_method = TinyFW.test_method(
|
original_method = TinyFW.test_method(
|
||||||
app=app, dut=dut, target=target, ci_target=upper_list_or_str(ci_target),
|
app=app, dut=dut, target=target, ci_target=upper_list_or_str(ci_target),
|
||||||
module=module, execution_time=execution_time, level=level, erase_nvs=erase_nvs,
|
module=module, execution_time=execution_time, level=level, erase_nvs=erase_nvs,
|
||||||
dut_dict=dut_classes, **kwargs
|
dut_dict=dut_classes, nightly_run=nightly_run, **kwargs
|
||||||
)
|
)
|
||||||
test_func = original_method(func)
|
test_func = original_method(func)
|
||||||
return test_func
|
return test_func
|
||||||
@ -138,7 +138,7 @@ def test_func_generator(func, app, target, ci_target, module, execution_time, le
|
|||||||
|
|
||||||
@ci_target_check
|
@ci_target_check
|
||||||
def idf_example_test(app=Example, target='ESP32', ci_target=None, module='examples', execution_time=1,
|
def idf_example_test(app=Example, target='ESP32', ci_target=None, module='examples', execution_time=1,
|
||||||
level='example', erase_nvs=True, config_name=None, **kwargs):
|
level='example', erase_nvs=True, config_name=None, nightly_run=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
decorator for testing idf examples (with default values for some keyword args).
|
decorator for testing idf examples (with default values for some keyword args).
|
||||||
|
|
||||||
@ -154,13 +154,14 @@ def idf_example_test(app=Example, target='ESP32', ci_target=None, module='exampl
|
|||||||
:return: test method
|
:return: test method
|
||||||
"""
|
"""
|
||||||
def test(func):
|
def test(func):
|
||||||
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, **kwargs)
|
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, nightly_run,
|
||||||
|
**kwargs)
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
||||||
@ci_target_check
|
@ci_target_check
|
||||||
def idf_unit_test(app=UT, target='ESP32', ci_target=None, module='unit-test', execution_time=1,
|
def idf_unit_test(app=UT, target='ESP32', ci_target=None, module='unit-test', execution_time=1,
|
||||||
level='unit', erase_nvs=True, **kwargs):
|
level='unit', erase_nvs=True, nightly_run=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
decorator for testing idf unit tests (with default values for some keyword args).
|
decorator for testing idf unit tests (with default values for some keyword args).
|
||||||
|
|
||||||
@ -174,14 +175,16 @@ def idf_unit_test(app=UT, target='ESP32', ci_target=None, module='unit-test', ex
|
|||||||
:param kwargs: other keyword args
|
:param kwargs: other keyword args
|
||||||
:return: test method
|
:return: test method
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test(func):
|
def test(func):
|
||||||
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, **kwargs)
|
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, nightly_run,
|
||||||
|
**kwargs)
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
||||||
@ci_target_check
|
@ci_target_check
|
||||||
def idf_custom_test(app=TestApp, target='ESP32', ci_target=None, module='misc', execution_time=1,
|
def idf_custom_test(app=TestApp, target='ESP32', ci_target=None, module='misc', execution_time=1,
|
||||||
level='integration', erase_nvs=True, config_name=None, **kwargs):
|
level='integration', erase_nvs=True, config_name=None, nightly_run=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
decorator for idf custom tests (with default values for some keyword args).
|
decorator for idf custom tests (with default values for some keyword args).
|
||||||
|
|
||||||
@ -196,14 +199,16 @@ def idf_custom_test(app=TestApp, target='ESP32', ci_target=None, module='misc',
|
|||||||
:param kwargs: other keyword args
|
:param kwargs: other keyword args
|
||||||
:return: test method
|
:return: test method
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test(func):
|
def test(func):
|
||||||
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, **kwargs)
|
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, nightly_run,
|
||||||
|
**kwargs)
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
||||||
@ci_target_check
|
@ci_target_check
|
||||||
def idf_component_unit_test(app=ComponentUTApp, target='ESP32', ci_target=None, module='misc', execution_time=1,
|
def idf_component_unit_test(app=ComponentUTApp, target='ESP32', ci_target=None, module='misc', execution_time=1,
|
||||||
level='integration', erase_nvs=True, config_name=None, **kwargs):
|
level='integration', erase_nvs=True, config_name=None, nightly_run=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
decorator for idf custom tests (with default values for some keyword args).
|
decorator for idf custom tests (with default values for some keyword args).
|
||||||
|
|
||||||
@ -220,7 +225,8 @@ def idf_component_unit_test(app=ComponentUTApp, target='ESP32', ci_target=None,
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def test(func):
|
def test(func):
|
||||||
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, **kwargs)
|
return test_func_generator(func, app, target, ci_target, module, execution_time, level, erase_nvs, nightly_run,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user