Преглед изворни кода

tiny-test-fw: revise unit test job config file:

`overwrite` should be included by each case config
He Yin Ling пре 6 година
родитељ
комит
74ca3fc571
2 измењених фајлова са 19 додато и 21 уклоњено
  1. 16 18
      tools/tiny-test-fw/CIAssignUnitTest.py
  2. 3 3
      tools/tiny-test-fw/Utility/CaseConfig.py

+ 16 - 18
tools/tiny-test-fw/CIAssignUnitTest.py

@@ -30,6 +30,11 @@ class Group(CIAssignTest.Group):
         "execution_time": "execution time"
     }
     CI_JOB_MATCH_KEYS = ["test environment"]
+    DUT_CLS_NAME = {
+        "esp32": "ESP32DUT",
+        "esp32s2beta": "ESP32S2DUT",
+        "esp8266": "ESP8266DUT",
+    }
 
     def __init__(self, case):
         super(Group, self).__init__(case)
@@ -89,33 +94,26 @@ class Group(CIAssignTest.Group):
         """
         test_function = self._map_test_function()
 
+        target = self._get_case_attr(self.case_list[0], "chip_target")
+        if target:
+            overwrite = {
+                "dut": {
+                    "path": "IDF/IDFDUT.py",
+                    "class": self.DUT_CLS_NAME[target],
+                }
+            }
+        else:
+            overwrite = dict()
         output_data = {
             # we don't need filter for test function, as UT uses a few test functions for all cases
             "CaseConfig": [
                 {
                     "name": test_function,
                     "extra_data": self._create_extra_data(test_function),
+                    "overwrite": overwrite,
                 }
             ],
         }
-
-        target = self._get_case_attr(self.case_list[0], "chip_target")
-        if target is not None:
-            target_dut = {
-                "esp32": "ESP32DUT",
-                "esp32s2beta": "ESP32S2DUT",
-                "esp8266": "ESP8266DUT",
-            }[target]
-            output_data.update({
-                "Filter": {
-                    "overwrite": {
-                        "dut": {
-                            "path": "IDF/IDFDUT.py",
-                            "class": target_dut,
-                        }
-                    }
-                }
-            })
         return output_data
 
 

+ 3 - 3
tools/tiny-test-fw/Utility/CaseConfig.py

@@ -159,7 +159,7 @@ class Parser(object):
         configs = cls.DEFAULT_CONFIG.copy()
         if config_file:
             with open(config_file, "r") as f:
-                configs.update(yaml.load(f), Loader=Loader)
+                configs.update(yaml.load(f, Loader=Loader))
         return configs
 
     @classmethod
@@ -190,9 +190,9 @@ class Parser(object):
         test_case_list = []
         for _config in configs["CaseConfig"]:
             _filter = configs["Filter"].copy()
+            _overwrite = cls.handle_overwrite_args(_config.pop("overwrite", dict()))
+            _extra_data = _config.pop("extra_data", None)
             _filter.update(_config)
-            _overwrite = cls.handle_overwrite_args(_filter.pop("overwrite", dict()))
-            _extra_data = _filter.pop("extra_data", None)
             for test_method in test_methods:
                 if _filter_one_case(test_method, _filter):
                     test_case_list.append(TestCase.TestCase(test_method, _extra_data, **_overwrite))