load all yml files while assigning tests
This commit is contained in:
parent
7709d4ccfd
commit
c131a18059
1 changed files with 27 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Command line tool to assign unit tests to CI test jobs.
|
Command line tool to assign unit tests to CI test jobs.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
@ -145,15 +145,33 @@ class UnitTestAssignTest(CIAssignTest.AssignTest):
|
||||||
The unit test cases is stored in a yaml file which is created in job build-idf-test.
|
The unit test cases is stored in a yaml file which is created in job build-idf-test.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def find_by_suffix(suffix, path):
|
||||||
|
res = []
|
||||||
|
for root, _, files in os.walk(path):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith(suffix):
|
||||||
|
res.append(os.path.join(root, file))
|
||||||
|
return res
|
||||||
|
|
||||||
|
def get_test_cases_from_yml(yml_file):
|
||||||
try:
|
try:
|
||||||
with open(test_case_path, "r") as f:
|
with open(yml_file) as fr:
|
||||||
raw_data = yaml.load(f, Loader=Loader)
|
raw_data = yaml.load(fr, Loader=Loader)
|
||||||
test_cases = raw_data["test cases"]
|
test_cases = raw_data['test cases']
|
||||||
for case in test_cases:
|
except (IOError, KeyError):
|
||||||
case["tags"] = set(case["tags"])
|
return []
|
||||||
except IOError:
|
else:
|
||||||
print("Test case path is invalid. Should only happen when use @bot to skip unit test.")
|
return test_cases
|
||||||
|
|
||||||
test_cases = []
|
test_cases = []
|
||||||
|
if os.path.isdir(test_case_path):
|
||||||
|
for yml_file in find_by_suffix('.yml', test_case_path):
|
||||||
|
test_cases.extend(get_test_cases_from_yml(yml_file))
|
||||||
|
elif os.path.isfile(test_case_path):
|
||||||
|
test_cases.extend(get_test_cases_from_yml(test_case_path))
|
||||||
|
else:
|
||||||
|
print("Test case path is invalid. Should only happen when use @bot to skip unit test.")
|
||||||
|
|
||||||
# filter keys are lower case. Do map lower case keys with original keys.
|
# filter keys are lower case. Do map lower case keys with original keys.
|
||||||
try:
|
try:
|
||||||
key_mapping = {x.lower(): x for x in test_cases[0].keys()}
|
key_mapping = {x.lower(): x for x in test_cases[0].keys()}
|
||||||
|
|
Loading…
Reference in a new issue