diff --git a/localCoverage/restore_comment/build_before_generate.py b/localCoverage/restore_comment/build_before_generate.py index d5dbfeb303866abce4f165a6342209875e25ee07..b13f32ea984e5c5ee139bd94ebb67a20a6bcc887 100644 --- a/localCoverage/restore_comment/build_before_generate.py +++ b/localCoverage/restore_comment/build_before_generate.py @@ -21,31 +21,6 @@ import subprocess import json -def get_file_list(find_path, postfix=""): - file_names = os.listdir(find_path) - file_list = [] - if len(file_names) > 0: - for fn in file_names: - if postfix != "": - if fn.find(postfix) != -1 and fn[-len(postfix):] == postfix: - file_list.append(fn) - else: - file_list.append(fn) - return - - -def get_file_list_by_postfix(path, postfix=""): - file_list = [] - for dirs in os.walk(path): - files = get_file_list(find_path=dirs[0], postfix=postfix) - for file_name in files: - if "" != file_name and -1 == file_name.find(__file__): - file_name = os.path.join(dirs[0], file_name) - if os.path.isfile(file_name): - file_list.append(file_name) - return file_list - - def get_source_file_list(path): """ 获取path路径下源文件路径列表 @@ -56,7 +31,7 @@ def get_source_file_list(path): for file_name in files: file_path = os.path.join(root, file_name) _, suffix = os.path.splitext(file_name) - if suffix in [".c", ".h", ".cpp"]: + if suffix in [".c", ".cpp"]: file_path_list_append(file_path) return file_path_list @@ -81,15 +56,18 @@ def rewrite_source_file(source_path_list: list): encoding="utf-8", errors="ignore") as write_fp: for line in code_lines: + sign_number = 0 for key in keys: + sign_number += 1 if key in line and line.strip().startswith(key): write_fp.write(line) break - elif " //LCOV_EXCL_BR_LINE" not in line and not line.strip().endswith("\\"): + elif " //LCOV_EXCL_BR_LINE" not in line and not line.strip().endswith("\\") \ + and sign_number == len(keys): write_fp.write(line.strip("\n").strip("\n\r") + " //LCOV_EXCL_BR_LINE") write_fp.write("\n") break - elif key == keys[-1]: + elif sign_number == len(keys): write_fp.write(line) break @@ -107,9 +85,11 @@ def add_lcov(subsystem_config_path): if "path" in value.keys(): for path_str in value["path"]: file_path = os.path.join(root_path, path_str) + primal_path = f"{file_path}_primal" if os.path.exists(file_path): - subprocess.Popen("cp -r %s %s" % ( - file_path, f"{file_path}_primal"), shell=True).communicate() + if not os.path.exists(primal_path): + subprocess.Popen("cp -r %s %s" % ( + file_path, primal_path), shell=True).communicate() source_file_path = get_source_file_list(file_path) rewrite_source_file(source_file_path) else: diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 3fa60f052615cee2d1360fd993795274b045b157..9da4366ab80fb71ccb230de3fb7e4600f19f264a 100644 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -101,8 +101,7 @@ class DisplayOutputReceiver: lines = self._process_output(output) for line in lines: line = line.strip() - if "[ RUN ]" in line or "[ OK ]" in line or "[==========]" in line or \ - "[----------]" in line or "[ PASSED ]" in line or "[ FAILED ]" in line: + if line: LOG.info(get_decode(line)) def __error__(self, message): @@ -567,7 +566,8 @@ class CppTestDriver(IDriver): serial = "{}_{}".format(str(request.config.device.__get_serial__()), time.time_ns()) log_tar_file_name = "{}_{}".format(request.get_module_name(), str(serial).replace( ":", "_")) - self.config.device.device_log_collector.stop_hilog_task(log_tar_file_name) + self.config.device.device_log_collector.stop_hilog_task( + log_tar_file_name, module_name=request.get_module_name()) def _init_gtest(self): self.config.device.connector_command("target mount") @@ -1198,9 +1198,13 @@ class OHRustTestDriver(IDriver): log_tar_file_name = "{}_{}".format( request.get_module_name(), str(serial).replace(":", "_")) self.config.device.device_log_collector.stop_hilog_task( - log_tar_file_name) + log_tar_file_name, module_name=request.get_module_name()) self.result = check_result_report( request.config.report_path, self.result, self.error_message) + result_save_path = get_result_savepath( + request.root.source.source_file, self.config.report_path) + shutil.move(self.result, result_save_path) + def _init_oh_rust(self): self.config.device.connector_command("target mount")