Pass current target to test_method **overwrite.

This commit is contained in:
Fu Hanxi 2020-04-08 11:32:25 +08:00
parent 6c98d7e4bd
commit 9f8b63da38
2 changed files with 14 additions and 2 deletions

View file

@ -180,17 +180,20 @@ def test_method(**kwargs):
if key in env_config:
env_config[key] = kwargs[key]
# Runner.py should overwrite target with the current target.
env_config.update(overwrite)
# FIXME: CI need more variable here. add `if CI_TARGET: ...` later with CI.
# This code block is used to run test script locally without
# Runner.py
target = env_config['target'] if 'target' in env_config else kwargs['target']
dut_dict = kwargs['dut_dict']
if isinstance(target, list):
target = target[0]
elif isinstance(target, str):
target = target
else:
raise TypeError('keyword targets can only be list or str')
dut_dict = kwargs['dut_dict']
if target not in dut_dict:
raise Exception('target can only be {%s}' % ', '.join(dut_dict.keys()))

View file

@ -190,6 +190,15 @@ class Parser(object):
_overwrite = cls.handle_overwrite_args(_config.pop("overwrite", dict()))
_extra_data = _config.pop("extra_data", None)
_filter.update(_config)
# Try get target from yml
try:
_target = _filter['target']
except KeyError:
pass
else:
_overwrite.update({'target': _target})
for test_method in test_methods:
if _filter_one_case(test_method, _filter):
test_case_list.append(TestCase.TestCase(test_method, _extra_data, **_overwrite))