From 2753716cb2dd246220c54cb163a2749b42882f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Wed, 27 Aug 2025 08:57:03 +0000 Subject: [PATCH 1/5] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- .../arkts_tdd_execute/arkts_tdd_build.py | 42 ++++++++++++------- .../arkts_tdd_report_generator.py | 7 +++- src/core/arkts_tdd/toolchain_hypium_build.py | 9 +++- src/core/command/run.py | 8 +++- src/core/testcase/testcase_manager.py | 1 + 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/core/arkts_tdd/arkts_tdd_execute/arkts_tdd_build.py b/src/core/arkts_tdd/arkts_tdd_execute/arkts_tdd_build.py index 50045cd..62bea51 100644 --- a/src/core/arkts_tdd/arkts_tdd_execute/arkts_tdd_build.py +++ b/src/core/arkts_tdd/arkts_tdd_execute/arkts_tdd_build.py @@ -53,6 +53,7 @@ def run_test(options): log_path = options.log_path result_path = os.path.join(report_folder_path, "result") + # 如果report下的result目录不存在则创建 if not os.path.exists(result_path): os.makedirs(result_path) @@ -63,8 +64,9 @@ def run_test(options): os.getcwd() result_construction = ResultConstruction() + # 定义测试执行时间 test_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - + # 执行测试套文件 for index, suite_file in enumerate(suite_file_list): run_abc_files(suite_file, log_path, testcases_path, result_path, index, suite_file_list, result_construction) @@ -76,13 +78,21 @@ def run_test(options): exec_info.log_path = log_path exec_info.platform = "" exec_info.execute_time = "" - + # 生成报告 result_report = ResultReporter() result_report.__generate_reports__(report_path=report_folder_path, task_info=exec_info) def write_output_to_log(result, log_file, testsuite_summary): + """ + 从子进程 stdout 中解析测试报告输出,提取测试套件/用例结果并写入日志文件。 + + Args: + result: subprocess.Popen 对象,包含 stdout + log_file: 日志文件对象(已打开,支持 write 和 flush) + testsuite_summary: 字典,用于存储汇总结果 + """ class_name = '' case_name = '' testcase_result = '' @@ -99,7 +109,7 @@ def write_output_to_log(result, log_file, testsuite_summary): if not output: continue line = output.rstrip().replace("\n", "").replace("\r", "").replace("\t", " ") - + # 1. 测试套件开始:[Hypium][suite start] if line.startswith('[Hypium][suite start]'): class_name = line.replace('[Hypium][suite start]', '') testsuite_summary[class_name] = {} @@ -107,11 +117,11 @@ def write_output_to_log(result, log_file, testsuite_summary): testcase_list = [] testsuite_summary[class_name]['case_detail'] = [] case_index = 0 - + # 2. 统计总用例数:OHOS_REPORT_SUM: if line.startswith('OHOS_REPORT_SUM:'): testsuite_case_num = line.replace('OHOS_REPORT_SUM:', '').strip() testsuite_summary[class_name]['testsuiteCaseNum'] = testsuite_case_num - + # 3. 新用例开始:OHOS_REPORT_STATUS: test= if line.startswith('OHOS_REPORT_STATUS: test='): testcase_map = {} testsuite_summary[class_name]['case_detail'].append(testcase_map) @@ -119,34 +129,35 @@ def write_output_to_log(result, log_file, testsuite_summary): case_name = line.replace('OHOS_REPORT_STATUS: test=', '') testcase_map['case_name'] = case_name case_index += 1 - + # 4. 提取用例执行结果(消耗时间) if case_name + ' ; consuming ' in line: testcase_result = get_testcase_result(case_index, case_name, class_name, line, testcase_map, testsuite_case_num) - + # 5. 失败详情:[Hypium][failDetail] if testcase_result == 'fail' and line.startswith('[Hypium][failDetail]'): testcase_faildetail = line.replace('[Hypium][failDetail]', '') testcase_map['testcaseFailDetail'] = testcase_faildetail - + # 6. 测试套总耗时:OHOS_REPORT_STATUS: suiteconsuming= if line.startswith('OHOS_REPORT_STATUS: suiteconsuming='): testsuite_consuming = line.replace('OHOS_REPORT_STATUS: suiteconsuming=', '') testsuite_summary[class_name]['testsuite_consuming'] = testsuite_consuming - + # 7. 测试套最终结果:OHOS_REPORT_RESULT: if line.startswith('OHOS_REPORT_RESULT:'): testsuites_result = line.replace("OHOS_REPORT_RESULT: stream=", "") testsuites_detail = testsuites_result.split(",") for detail in testsuites_detail: detail_temp = detail.split(":") testsuite_summary[detail_temp[0].strip()] = detail_temp[1].strip() - + # 8. 任务总耗时:OHOS_REPORT_STATUS: taskconsuming= if line.startswith('OHOS_REPORT_STATUS: taskconsuming='): taskconsuming = line.replace("OHOS_REPORT_STATUS: taskconsuming=", "") testsuite_summary["taskconsuming"] = taskconsuming - # 将输出写入文件 + # 将输出写入日志文件 log_file.write(output) log_file.flush() # 确保内容立即写入文件 def get_testcase_result(case_index, case_name, class_name, line, testcase_map, testsuite_case_num): + # 提取用例执行结果(消耗时间) testcase_result = line[9:13] consuming_list = line.split(case_name + ' ; consuming ') testcase_consuming = '0' @@ -161,11 +172,13 @@ def get_testcase_result(case_index, case_name, class_name, line, testcase_map, t def run_abc_files(suite_file, log_path, testcases_path, result_path, index, suite_file_list, result_construction): file_name = os.path.basename(suite_file) prefix_name, suffix_name = os.path.splitext(file_name) + # 获取测试套名 suite_name = prefix_name + # 定义log path suite_log_path = os.path.join(log_path, prefix_name) if not os.path.exists(suite_log_path): os.makedirs(suite_log_path) - + # 获取测试套用例执行结果的xml生成路径 suite_file_path = os.path.dirname(suite_file) module_output_path = suite_file_path.replace(testcases_path, "") suite_result_path = os.path.join(result_path, module_output_path.lstrip("/").lstrip("\\")) @@ -194,7 +207,7 @@ def run_abc_files(suite_file, log_path, testcases_path, result_path, index, suit result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) with open(log_file, "a") as log_file: - # 启动线程,实时读取输出并写入文件 + # 启动线程,实时读取输出并写入文件,同时存储用例执行结果 thread = threading.Thread(target=write_output_to_log, args=(result, log_file, testsuite_summary)) thread.start() @@ -213,8 +226,9 @@ def run_abc_files(suite_file, log_path, testcases_path, result_path, index, suit result_construction.start_time = start_time result_construction.end_time = end_time result_construction.suite_file_name = suite_name + # 构建xml节点 result_construction.node_construction(suite_result_file) - + # 执行异常处理 if return_message != "": error_message = str(return_message) error_message = error_message.replace("\"", "") diff --git a/src/core/arkts_tdd/artts_tdd_report/arkts_tdd_report_generator.py b/src/core/arkts_tdd/artts_tdd_report/arkts_tdd_report_generator.py index b198fa1..2863443 100644 --- a/src/core/arkts_tdd/artts_tdd_report/arkts_tdd_report_generator.py +++ b/src/core/arkts_tdd/artts_tdd_report/arkts_tdd_report_generator.py @@ -44,6 +44,7 @@ class ResultConstruction(object): elem_node.tail = "\n" + level * " " def set_testsuites_element(self, testsuites): + # 构造testsuites的节点信息 testsuites.set("name", self.suite_file_name) testsuites.set("timestamp", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) testsuites.set("time", str(float(self.testsuite_summary['taskconsuming']) / 1000)) @@ -60,6 +61,7 @@ class ResultConstruction(object): testsuites.set("test_type", "OHJSUnitTest") def node_construction(self, suite_result_file): + # 构造xml文件的节点信息 # 创建根元素 testsuites = ET.Element("testsuites") self.set_testsuites_element(testsuites) @@ -73,7 +75,7 @@ class ResultConstruction(object): for detail in case_detail: if detail['testcaseResult'] == 'fail': fail_count += 1 - + # 构造testsuite的节点信息 testsuite.set("name", key) testsuite.set("time", str(float(value['testsuite_consuming']) / 1000)) testsuite.set("errors", "0") @@ -82,7 +84,7 @@ class ResultConstruction(object): testsuite.set("ignored", "0") testsuite.set("tests", value['testsuiteCaseNum']) testsuite.set("report", "") - + # 构造testcase的节点信息 case_detail = value['case_detail'] for detail in case_detail: testcase = ET.SubElement(testsuite, "testcase") @@ -101,6 +103,7 @@ class ResultConstruction(object): failure.set("message", detail['testcaseFailDetail']) failure.set("type", "") failure.text = detail['testcaseFailDetail'] + # 美化xml格式 self.format_xml(testsuites) # 将 ElementTree 写入 XML 文件 diff --git a/src/core/arkts_tdd/toolchain_hypium_build.py b/src/core/arkts_tdd/toolchain_hypium_build.py index 38e8d8f..f8b0d72 100644 --- a/src/core/arkts_tdd/toolchain_hypium_build.py +++ b/src/core/arkts_tdd/toolchain_hypium_build.py @@ -43,6 +43,9 @@ def get_path_code_directory(after_dir): def run_command(command): + """ + 执行编译工具链命令 + """ try: print(f'{"*" * 35}开始执行命令:{command}{"*" * 35}') command_list = command.split(" ") @@ -71,6 +74,9 @@ def create_soft_link(target_path, link_path): def run_toolchain_build(): + """ + 调用公共方法执行编译工具链命令 + """ static_core_path = get_path_code_directory(STATICCOREPATH) os.path.join(static_core_path, "tools") current_dir = os.path.join(static_core_path, "tools") @@ -225,7 +231,7 @@ def build_tools(compile_filelist, hypium_output_dir): def collect_abc_files(output_dir): abc_files = [] - # 1. 收集out目录下的.abc文件 + # 收集out目录下的.abc文件 if os.path.exists(output_dir): out_files = [ os.path.join(output_dir, f) @@ -319,6 +325,7 @@ def main(): static_core_path = get_path_code_directory(STATICCOREPATH) #清空上次编译结果 remove_directory_contents(os.path.join(static_core_path, "out")) + #执行编译工具链命令 run_toolchain_build() third_party_path = os.path.join(static_core_path, "third_party") #删除third_party路径下的bundle.json防止编译出错 diff --git a/src/core/command/run.py b/src/core/command/run.py index 7125395..5bc6252 100644 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -363,14 +363,17 @@ class Run(object): options.testdict = test_dict options.target_outpath = self.get_target_out_path( options.productform) + # 开始执行arktstdd用例 if "arktstdd" in options.testtype: local_time = time.localtime() create_time = time.strftime('%Y-%m-%d-%H-%M-%S', local_time) + # 定义report目录 result_rootpath = os.path.join(sys.framework_root_dir, "reports", create_time) log_path = os.path.join(result_rootpath, "log") os.makedirs(log_path, exist_ok=True) - + # report目录 options.result_rootpath = result_rootpath + # log目录 options.log_path = log_path test_case_path = self.get_tests_out_path(options.productform) @@ -379,8 +382,9 @@ class Run(object): return Binder.get_runtime_log().start_task_log(log_path) - + # 测试用例路径 options.testcases_path = os.path.join(test_case_path, options.testtype[0]) + # 用例执行及报告生成 run_test(options) Binder.get_runtime_log().stop_task_logcat() else: diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 115adee..e71344e 100644 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -292,6 +292,7 @@ class TestCaseManager(object): suite_file_dictionary.get("CXX").append(suite_file) elif suffix_name == ".bin": suite_file_dictionary.get("BIN").append(suite_file) + # 将arktstdd的测试文件加入测试文件字典 elif (suffix_name == ".abc" and not os.path.dirname(suite_file).endswith("out") and not os.path.dirname(suite_file).endswith("hypium")): suite_file_dictionary.get("ABC").append(suite_file) -- Gitee From 2bf9f9ad63c06d6c742de06484ab0bd075788c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Thu, 11 Sep 2025 03:26:03 +0000 Subject: [PATCH 2/5] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- src/core/command/console.py | 8 +++ src/core/command/run.py | 1 + src/core/driver/drivers.py | 31 +++++++---- src/core/driver/openharmony.py | 20 +++++-- src/core/testcase/testcase_manager.py | 78 ++++++++++++++++++++++++++- 5 files changed, 124 insertions(+), 14 deletions(-) diff --git a/src/core/command/console.py b/src/core/command/console.py index 79fdcf6..f1b00f2 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -230,6 +230,13 @@ class Console(object): default="", help="Specify test suites list file" ) + parser.add_argument("-tcf", "--testcasefile", + action="store", + type=str, + dest="testcasefile", + default="", + help="Add the test case to be executed to the JSON config file" + ) parser.add_argument("-res", "--resource", action="store", type=str, @@ -483,6 +490,7 @@ class ConfigConst(object): testlist = "testlist" testfile = "testfile" testcase = "testcase" + testcasefile = "testcasefile" testdict = "testdict" device_sn = "device_sn" report_path = "report_path" diff --git a/src/core/command/run.py b/src/core/command/run.py index 5bc6252..9b442e7 100644 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -214,6 +214,7 @@ class Run(object): LOG.info("runhistory = %s" % options.runhistory) LOG.info("partname_list = %s" % str(options.partname_list)) LOG.info("partdeps = %s" % options.partdeps) + LOG.info("testcase_file = %s" % options.testcasefile) LOG.info("------------------------------------") LOG.info("") diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 20ad447..4aeac6c 100644 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -574,6 +574,7 @@ class CppTestDriver(IDriver): self.config = request.config self.config.target_test_path = DEFAULT_TEST_PATH self.config.device = request.config.environment.devices[0] + self.config.test_level_dict = request.config.test_level_dict suite_file = request.root.source.source_file LOG.debug("Testsuite FilePath: %s" % suite_file) @@ -652,13 +653,19 @@ class CppTestDriver(IDriver): def _gtest_command(self, suite_file): filename = os.path.basename(suite_file) - test_para = self._get_test_para(self.config.testcase, + if self.config.testcase: + testcase = self.config.testcase + else: + testcase = self.config.tesecase_dict["CXX"].get(filename, "") + test_para = self._get_test_para(testcase, + self.config.testcase, self.config.testlevel, self.config.testtype, self.config.target_test_path, suite_file, filename, - self.config.iteration) + self.config.iteration, + self.config.test_level_dict.get(suite_file, "")) # execute testcase if not self.config.coverage: @@ -808,7 +815,8 @@ class CppTestDriver(IDriver): target_test_path, suite_file, filename, - iteration): + iteration, + case_level=""): if "benchmark" == testtype[0]: test_para = (" --benchmark_out_format=json" " --benchmark_out=%s%s.json") % ( @@ -817,9 +825,12 @@ class CppTestDriver(IDriver): if "" != testcase and "" == testlevel: test_para = "%s=%s" % (GTestConst.exec_para_filter, testcase) - elif "" == testcase and "" != testlevel: + elif "" == testcase and "" != testlevel and not case_level: level_para = get_level_para_string(testlevel) test_para = "%s=%s" % (GTestConst.exec_para_level, level_para) + elif "" == testcase and not testlevel and case_level: + level_para = get_level_para_string(case_level) + test_para = "%s=%s" % (GTestConst.exec_para_level, level_para) else: test_para = "" @@ -875,23 +886,23 @@ class JSUnitTestDriver(IDriver): self.config.target_test_path = DEFAULT_TEST_PATH self.config.device = request.config.environment.devices[0] - suite_file = request.root.source.source_file - result_save_path = get_result_savepath(suite_file, self.config.report_path) + self.suite_file = request.root.source.source_file + result_save_path = get_result_savepath(self.suite_file, self.config.report_path) self.result = os.path.join(result_save_path, "%s.xml" % request.get_module_name()) - if not suite_file: + if not self.suite_file: LOG.error("test source '%s' not exists" % request.root.source.source_string) return if not self.config.device: - result = ResultManager(suite_file, self.config) + result = ResultManager(self.suite_file, self.config) result.set_is_coverage(False) result.make_empty_result_file( "No test device is found") return package_name, ability_name = self._get_package_and_ability_name( - suite_file) + self.suite_file) self.package_name = package_name self.ability_name = ability_name self.config.test_hap_out_path = \ @@ -912,7 +923,7 @@ class JSUnitTestDriver(IDriver): _, self.hilog_proc = self.config.device.device_log_collector.\ start_catch_device_log(hilog_file_pipe=hilog_file_pipe) self._init_jsunit_test() - self._run_jsunit(suite_file, self.hilog) + self._run_jsunit(self.suite_file, self.hilog) hilog_file_pipe.flush() self.generate_console_output(self.hilog, request) xml_path = os.path.join( diff --git a/src/core/driver/openharmony.py b/src/core/driver/openharmony.py index fd0ea8f..8eead9f 100644 --- a/src/core/driver/openharmony.py +++ b/src/core/driver/openharmony.py @@ -59,8 +59,8 @@ def oh_jsunit_para_parse(runner, junit_paras): for para_name in junit_paras.keys(): para_name = para_name.strip() para_values = junit_paras.get(para_name, []) - if para_name == "class": - runner.add_arg(para_name, ",".join(para_values)) + if para_name == "class" or para_name in ["HAP", "CXX"]: + runner.add_arg("class", ",".join(para_values)) elif para_name == "notClass": runner.add_arg(para_name, ",".join(para_values)) elif para_name == "testType": @@ -309,7 +309,21 @@ class OHJSUnitTestDriver(IDriver): # execute test case self._do_tf_suite() self._make_exclude_list_file(request) - oh_jsunit_para_parse(self.runner, self.config.testargs) + if self.config.get("testcasefile"): + suite_file = request.root.source.source_file + prefix_name, _ = os.path.splitext(os.path.basename(suite_file)) + testcase = self.config.testcase_dict.get("OHJST", {}).get(prefix_name, []) + level = self.config.test_level_dict.get(suite_file, "") + testargs = {} + if testcase: + testcase = [testcase] + testargs = {"class": testcase} + + if level and not testcase: + testargs = {"level": level} + oh_jsunit_para_parse(self.runner, testargs) + else: + oh_jsunit_para_parse(self.runner, self.config.testargs) self._do_test_run(listener=request.listeners) finally: diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index e71344e..204c771 100644 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -216,6 +216,19 @@ class TestCaseManager(object): return suit_file_dictionary def get_all_test_file(self, test_case_out_path, options): + testcase_dict = { + "DEX": [], + "HAP": [], + "PYT": [], + "CXX": [], + "BIN": [], + "OHJST": [], + "JST": [], + "LTPPosix": [], + "OHRust": [], + "ABC": [] + } + test_level_dict = {} suite_file_dictionary = copy.deepcopy(TESTFILE_TYPE_DATA_DIC) filter_part_list = FilterConfigManager().get_filtering_list( "subsystem_name", options.productform) @@ -223,13 +236,26 @@ class TestCaseManager(object): "testfile_name", options.productform) # 遍历测试用例输出目录下面的所有文件夹,每个文件夹对应一个子系统 command_list = options.current_raw_cmd.split(" ") + # testcase_json + testcase_json = options.testcasefile + if not testcase_json or not os.path.exists(testcase_json): + return suite_file_dictionary + + testcase_json_dic = {} + if os.part.exists(testcase_json) and testcase_json.endswith(".json"): + testcase_json_dic = json.load(open(testcase_json)) + for part_name in os.listdir(test_case_out_path): if "-ss" in command_list or "-tp" in command_list: if part_name not in options.partname_list: continue + if testcase_json_dic and part_name not in testcase_json_dic: + continue + part_case_dir = os.path.join(test_case_out_path, part_name) if not os.path.isdir(part_case_dir): continue + # 如果子系统在fiter_config.xml配置文件的下面配置过,则过滤 if part_name in filter_part_list: continue @@ -251,6 +277,36 @@ class TestCaseManager(object): if suffix_name in FILTER_SUFFIX_NAME_LIST: continue + testcase_list = [] + level = "" + if testcase_json_dic: + part_test_dic = testcase_json_dic.get(part_name, {}) + if "level" in part_test_dic.keys(): + level = part_test_dic.pop("level", "") + + module_name = suite_file.replace(part_case_dir, "").replace( + "\\", "/").strip("/").split("/")[0] + + if part_test_dic and module_name not in part_test_dic: + continue + + module_test_dic = part_test_dic.get(module_name, {}) + if "level" in module_test_dic.keys(): + level = module_test_dic.pop("level", "") + + if module_test_dic and prefix_name not in module_test_dic: + continue + + if suffix_name not in [".dex", ".hap", ".py", ".bin", ""]: + continue + + if module_test_dic and module_test_dic.get(prefix_name): + testcase_list = module_test_dic.get(prefix_name).get("testcase", []) + if not testcase_list: + level = module_test_dic.get(prefix_name).get("level", "") + if level in ["0", "1", "2", "3", "4"]: + test_level_dict[suite_file] = level + if not self.get_valid_suite_file(test_case_out_path, suite_file, options): @@ -258,6 +314,8 @@ class TestCaseManager(object): if suffix_name == ".dex": suite_file_dictionary.get("DEX").append(suite_file) + if testcase_list + testcase_dict["DEX"][prefix_name] = ":".join(testcase_list) elif suffix_name == ".hap": if self.get_hap_test_driver(suite_file) == "OHJSUnitTest": # 如果stage测试指定了-tp,只有部件名与moduleInfo中part一致的HAP包才会加入最终执行的队列 @@ -276,27 +334,45 @@ class TestCaseManager(object): continue if not self.check_hap_test_file(suite_file): continue + suite_file_dictionary.get("OHJST").append(suite_file) + if testcase_list: + testcase_dict["OHJST"][]prefix_name = ":".join(testcase_list) if self.get_hap_test_driver(suite_file) == "JSUnitTest": suite_file_dictionary.get("JST").append(suite_file) + if testcase_list: + testcase_dict["JST"][]prefix_name = ":".join(testcase_list) elif suffix_name == ".py": if not self.check_python_test_file(suite_file): continue + suite_file_dictionary.get("PYT").append(suite_file) + if testcase_list: + testcase_dict["PYT"][]prefix_name = ":".join(testcase_list) elif suffix_name == "": if file_name.startswith("rust_"): Binder.get_tdd_config().update_test_type_in_source( "OHRust", DeviceTestType.oh_rust_test) suite_file_dictionary.get("OHRust").append(suite_file) + if testcase_list: + testcase_dict["OHRUST"][]prefix_name = ":".join(testcase_list) else: suite_file_dictionary.get("CXX").append(suite_file) + if testcase_list: + testcase_dict["CXX"][]prefix_name = ":".join(testcase_list) elif suffix_name == ".bin": suite_file_dictionary.get("BIN").append(suite_file) + if testcase_list: + testcase_dict["BIN"][]prefix_name = ":".join(testcase_list) # 将arktstdd的测试文件加入测试文件字典 elif (suffix_name == ".abc" and not os.path.dirname(suite_file).endswith("out") and not os.path.dirname(suite_file).endswith("hypium")): suite_file_dictionary.get("ABC").append(suite_file) - + if testcase_list: + testcase_dict["ABC"][]prefix_name = ":".join(testcase_list) + + options.testcase_dict = testcase_dict + options.test_level_dict = test_level_dict return suite_file_dictionary def get_part_deps_files(self, external_deps_path, testpart): -- Gitee From 3bd50a0f24ae9db1e37cb6dacc419d74fc96dc71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Thu, 11 Sep 2025 03:33:30 +0000 Subject: [PATCH 3/5] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- src/core/driver/drivers.py | 2 +- src/core/testcase/testcase_manager.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 4aeac6c..d1bb4a2 100644 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -656,7 +656,7 @@ class CppTestDriver(IDriver): if self.config.testcase: testcase = self.config.testcase else: - testcase = self.config.tesecase_dict["CXX"].get(filename, "") + testcase = self.config.tesecase_dict.get("CXX", {}).get(filename, "") test_para = self._get_test_para(testcase, self.config.testcase, self.config.testlevel, diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 204c771..e41ff1a 100644 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -242,7 +242,7 @@ class TestCaseManager(object): return suite_file_dictionary testcase_json_dic = {} - if os.part.exists(testcase_json) and testcase_json.endswith(".json"): + if os.path.exists(testcase_json) and testcase_json.endswith(".json"): testcase_json_dic = json.load(open(testcase_json)) for part_name in os.listdir(test_case_out_path): @@ -304,6 +304,7 @@ class TestCaseManager(object): testcase_list = module_test_dic.get(prefix_name).get("testcase", []) if not testcase_list: level = module_test_dic.get(prefix_name).get("level", "") + if level in ["0", "1", "2", "3", "4"]: test_level_dict[suite_file] = level -- Gitee From 61f7a06f6c3c536cd881b3a6901f3bfe48aeddf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Thu, 11 Sep 2025 12:22:07 +0000 Subject: [PATCH 4/5] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- src/core/driver/openharmony.py | 2 +- src/core/testcase/testcase_manager.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/driver/openharmony.py b/src/core/driver/openharmony.py index 8eead9f..693687f 100644 --- a/src/core/driver/openharmony.py +++ b/src/core/driver/openharmony.py @@ -323,7 +323,7 @@ class OHJSUnitTestDriver(IDriver): testargs = {"level": level} oh_jsunit_para_parse(self.runner, testargs) else: - oh_jsunit_para_parse(self.runner, self.config.testargs) + oh_jsunit_para_parse(self.runner, self.config.testargs) self._do_test_run(listener=request.listeners) finally: diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index e41ff1a..285050a 100644 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -297,14 +297,14 @@ class TestCaseManager(object): if module_test_dic and prefix_name not in module_test_dic: continue - if suffix_name not in [".dex", ".hap", ".py", ".bin", ""]: + if suffix_name not in [".dex", ".hap", ".py", ".bin", None]: continue if module_test_dic and module_test_dic.get(prefix_name): testcase_list = module_test_dic.get(prefix_name).get("testcase", []) if not testcase_list: level = module_test_dic.get(prefix_name).get("level", "") - + if level in ["0", "1", "2", "3", "4"]: test_level_dict[suite_file] = level -- Gitee From e1c7fff315c46e542babccacf4dee00ac0a245ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Thu, 11 Sep 2025 12:29:55 +0000 Subject: [PATCH 5/5] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- src/core/testcase/testcase_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 285050a..7650e8b 100644 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -297,7 +297,7 @@ class TestCaseManager(object): if module_test_dic and prefix_name not in module_test_dic: continue - if suffix_name not in [".dex", ".hap", ".py", ".bin", None]: + if suffix_name not in [".dex", ".hap", ".py", ".bin", ""]: continue if module_test_dic and module_test_dic.get(prefix_name): -- Gitee