Răsfoiți Sursa

Merge branch 'bugfix/duplicate_unit_test_case_id' into 'master'

CI: fix bug that generates duplicate unit test case ID

See merge request !813

Ivan Grokhotkov 8 ani în urmă
părinte
comite
e45a288516
2 a modificat fișierele cu 20 adăugiri și 6 ștergeri
  1. 6 0
      .gitlab-ci.yml
  2. 14 6
      tools/unit-test-app/tools/UnitTestParser.py

+ 6 - 0
.gitlab-ci.yml

@@ -436,6 +436,12 @@ UT_001_03:
     - ESP32_IDF
     - UT_T1_1
 
+UT_001_04:
+  <<: *unit_test_template
+  tags:
+    - ESP32_IDF
+    - UT_T1_1
+
 IT_001_01:
   <<: *test_template
   tags:

+ 14 - 6
tools/unit-test-app/tools/UnitTestParser.py

@@ -3,6 +3,7 @@ import os
 import re
 import shutil
 import subprocess
+import hashlib
 
 from copy import deepcopy
 import CreateSectionTable
@@ -131,16 +132,23 @@ class Parser(object):
         :return: parsed test case
         """
         prop = self.parse_case_properities(description)
-
-        if file_name in self.file_name_cache:
-            self.file_name_cache[file_name] += 1
+        
+        idf_path = os.getenv("IDF_PATH")
+        
+        # use relative file path to IDF_PATH, to make sure file path is consist
+        relative_file_path = os.path.relpath(file_name, idf_path)
+        
+        file_name_hash = int(hashlib.sha256(relative_file_path).hexdigest(), base=16) % 1000
+
+        if file_name_hash in self.file_name_cache:
+            self.file_name_cache[file_name_hash] += 1
         else:
-            self.file_name_cache[file_name] = 1
+            self.file_name_cache[file_name_hash] = 1
 
         tc_id = "UT_%s_%s_%03d%02d" % (self.module_map[prop["module"]]['module abbr'],
                                        self.module_map[prop["module"]]['sub module abbr'],
-                                       hash(file_name) % 1000,
-                                       self.file_name_cache[file_name])
+                                       file_name_hash,
+                                       self.file_name_cache[file_name_hash])
         test_case = deepcopy(TEST_CASE_PATTERN)
         test_case.update({"module": self.module_map[prop["module"]]['module'],
                           "CI ready": "No" if prop["ignore"] == "Yes" else "Yes",