Explorar o código

Pass current target to test_method **overwrite.

Fu Hanxi %!s(int64=5) %!d(string=hai) anos
pai
achega
9f8b63da38

+ 5 - 2
tools/ci/python_packages/tiny_test_fw/TinyFW.py

@@ -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()))
 

+ 9 - 0
tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py

@@ -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))