From 0b81d478cbcfb7d17687a6b92903fd23bf184076 Mon Sep 17 00:00:00 2001 From: mipengwei Date: Mon, 25 Jul 2022 03:14:48 +0000 Subject: [PATCH] Signed-off-by:mipengwei --- src/core/build/build_manager.py | 13 ------------- src/core/build/build_testcases.py | 11 +++-------- src/core/build/select_targets.py | 25 +++---------------------- src/core/command/console.py | 17 +---------------- src/core/command/display.py | 10 ---------- src/core/config/config_manager.py | 27 --------------------------- src/core/config/parse_parts_config.py | 16 ++-------------- src/core/testcase/testcase_manager.py | 13 ++++--------- src/core/utils.py | 3 --- src/main/_init_global_config.py | 20 -------------------- 10 files changed, 13 insertions(+), 142 deletions(-) diff --git a/src/core/build/build_manager.py b/src/core/build/build_manager.py index b0cf72d..0113b44 100755 --- a/src/core/build/build_manager.py +++ b/src/core/build/build_manager.py @@ -48,10 +48,6 @@ class BuildManager(object): gn_file.write(" ]\n") gn_file.write("}\n") - # 根据目标编译测试用例 - # project_root_path 工程根目录 - # product_form 产品形态,指令第一步选择的产品 - # build_target 编译目标 @classmethod def _compile_test_cases_by_target(cls, project_root_path, product_form, build_target): @@ -64,9 +60,6 @@ class BuildManager(object): build_result = False return build_result - # 根据目标编译acts测试用例 - # project_root_path 工程根目录 - # para 指令参数 @classmethod def _compile_acts_test_cases(cls, project_root_path, para): if BuildTestcases(project_root_path).build_acts_testcases(para): @@ -87,23 +80,19 @@ class BuildManager(object): LOG.info("Test case compilation failed, please modify.") return build_result - # 编译入口 def _compile_testcases(self, project_root_path, para): - # 获取所有支持的产品,3.1Release版本为["DAYU","Hi3516DV300","ohos-arm64","ohos-sdk","rk3568"] all_product_list = scan_support_product() if para.productform not in all_product_list: from core.build.build_lite_manager import BuildLiteManager build_lite_manager = BuildLiteManager(project_root_path) return build_lite_manager.build_testcases(para) - # 如果测试集不为空,build_target为测试集 if para.testsuit != "": return self._compile_test_cases_by_target( project_root_path, para.productform, para.testsuit) - # 如果测试集为空,部件列表为空,模块列表为空,测试类型中含有“ALL”,build_target为"make_test" if (len(para.partname_list) == 0 and para.testmodule == "" and "ALL" in para.testtype): return self._compile_test_cases_by_target( @@ -111,14 +100,12 @@ class BuildManager(object): para.productform, "make_test") - # 如果测试集为空,三个条件(部件列表为空,模块列表为空,测试类型中含有“ALL”)不同时成立 target_list = SelectTargets( project_root_path).filter_build_targets(para) if len(target_list) == 0: LOG.warning("No build target found.") return False - # 路径拼接 build_cfg_filepath = OpenHarmony/test/developertest/BUILD.gn build_cfg_filepath = os.path.join(project_root_path, "test", "developertest", diff --git a/src/core/build/build_testcases.py b/src/core/build/build_testcases.py index 95351c0..f9dd533 100755 --- a/src/core/build/build_testcases.py +++ b/src/core/build/build_testcases.py @@ -73,8 +73,6 @@ class BuildTestcases(object): return "" testcase_outpath = "" - - # 路径注释 get_build_output_path = OpenHarmony/out/rk3568/build_configs/platforms_info/toolchain_to_variant.json toolchain_filepath = os.path.join( get_build_output_path(productform), "build_configs", @@ -102,7 +100,7 @@ class BuildTestcases(object): "acts", "testcases") LOG.info("acts_testcase_out_dir=%s" % acts_testcase_out_dir) - # 删除~/OpenHarmony/out/rk3568/suites/acts/testcases目录内容 + if os.path.exists(acts_testcase_out_dir): shutil.rmtree(acts_testcase_out_dir) @@ -121,14 +119,14 @@ class BuildTestcases(object): "tests") LOG.info("package_out_dir=%s" % package_out_dir) - # 删除~/OpenHarmony/out/rk3568/packages/phone/tests目录内容 + if os.path.exists(package_out_dir): shutil.rmtree(package_out_dir) phone_out_dir = os.path.join( self.project_rootpath, "out", "release", "tests") LOG.info("phone_out_dir=%s" % phone_out_dir) - # 删除~/OpenHarmony/out/release/tests目录内容 + if os.path.exists(phone_out_dir): shutil.rmtree(phone_out_dir) @@ -203,7 +201,6 @@ class BuildTestcases(object): build_result = False acts_build_command = [] current_path = os.getcwd() - # 路径 acts_rootpath = ~/OpenHarmony/test/xts/acts os.chdir(self.xts_project_rootpath) acts_build_command.append(BUILD_PRODUCT_NAME % para.productform) acts_build_command.append("system_size=standard") @@ -240,7 +237,6 @@ class BuildTestcases(object): self._merge_testcase_dir(para.productform) return build_result - # 编译测试用例(编译命令拼接) def build_testcases(self, productform, target): command = [] if self.is_build_example: @@ -255,7 +251,6 @@ class BuildTestcases(object): self._merge_testcase_dir(productform) return build_result - # 编译ACTS测试用例 def build_acts_testcases(self, para): self._delete_acts_testcase_dir(para.productform) build_result = self._execute_build_acts_command(para) diff --git a/src/core/build/select_targets.py b/src/core/build/select_targets.py index ce6c88c..f5a9c4b 100755 --- a/src/core/build/select_targets.py +++ b/src/core/build/select_targets.py @@ -48,7 +48,6 @@ class SelectTargets(object): def _get_part_path_data(cls, productform): part_path_dic = {} parser = ParsePartsConfig(productform) - # 获取infos_for_testfwk.json配置文件中“phone”节点下“part_infos”节点数据 part_infos = parser.get_part_infos() if part_infos is None: LOG.error("part_infos is None.") @@ -63,14 +62,12 @@ class SelectTargets(object): build_out_dir = part_info.get("build_out_dir") part_path_list = [] - # default_part_path:~/OpenHarmony/out/rk3568/module_list_files/部件名(以rk3568举例) default_part_path = os.path.join( get_build_output_path(productform), "module_list_files", origin_part_name) if os.path.exists(default_part_path): part_path_list.append(default_part_path) - # 如果build_out_dir不是当前目录,将新目录加到part_path_list中 if build_out_dir != ".": product_part_path = os.path.join( get_build_output_path(productform), @@ -85,18 +82,12 @@ class SelectTargets(object): def _get_target_list_from_path(self, typelist, check_path): target_list = [] if os.path.exists(check_path): - # 获取部件编译输出目录(~/OpenHarmony/out/rk3568/module_list_files/部件名1)中.mlf文件列表 mlf_file_list = get_file_list_by_postfix( check_path, ".mlf") - # 遍历mlf_file_list中所有目录下面mlf文件中的label列表 for filepath in mlf_file_list: - # 获取mlf文件中的JSON数据信息列表 mlf_info_list = self._get_mlf_data_from_file(filepath) for data in mlf_info_list: - # 举例:"test_type": "moduletest" test_type = data.get("test_type") - # 举例:"label": "//base/accessibility/services/test:aams_accessibility_keyevent_filter_test - # (//build/toolchain/ohos:ohos_clang_arm)" target_path = data.get("label") if "ALL" in typelist: target_list.append(target_path) @@ -107,8 +98,6 @@ class SelectTargets(object): def _get_target_list_by_type(self, productform, typelist): target_list = [] - # 获取所有部件编译输出信息列表:[{“部件名1”:[~/OpenHarmony/out/rk3568/module_list_files/部件名1]}] - # 或者{“部件名1”:[~/OpenHarmony/out/rk3568/module_list_files/部件名1,~/OpenHarmony/out/rk3568/编译目录build_out_dir/module_list_files/部件名1]} part_path_dic = self._get_part_path_data(productform) for item in part_path_dic: part_path_list = part_path_dic.get(item) @@ -156,19 +145,16 @@ class SelectTargets(object): LOG.warning( "The part cannot be empty When the module is not empty.") return [] - # productform不为空,typelist(test type[UT,MST,ST,PERF,ALL])不为空 - # partlist和testmodule为空,通过testtype获取部件列表 + if len(partlist) == 0 and testmodule == "": target_list = self._get_target_list_by_type(productform, typelist) return target_list - # productform不为空,typelist(test type[UT,MST,ST,PERF,ALL])不为空 - # partlist不为空,testmodule为空,通过testtype、partlist一起获取部件列表 + if len(partlist) != 0 and testmodule == "": target_list = self._get_target_list_by_part(productform, typelist, partlist) return target_list - # productform不为空,typelist(test type[UT,MST,ST,PERF,ALL])不为空 - # partlist不为空,testmodule不为空,通过testtype、partlist、testmodule一起获取部件列表 + if len(partlist) != 0 and testmodule != "": target_list = self._get_target_list_by_module(productform, typelist, @@ -177,11 +163,6 @@ class SelectTargets(object): return target_list - # 通过infos_for_testfwk.json文件获取所有子部件信息编译目录信息: - # [{“部件名1”:[~/OpenHarmony/out/rk3568/module_list_files/部件名1]}] - # 然后遍历这些目录中的mlf文件,获取其中定义的label,返回label集合 - # 遍历时通过testmodule控制遍历的部件指定模块目录,如果不定义,则遍历子部件下面所有模块目录 - # 遍历时通过partlist控制遍历指定部件目录,如果不定义,则遍历infos_for_testfwk.json文件中定义的所有子部件目录 def filter_build_targets(self, para): productform = para.productform typelist = para.testtype diff --git a/src/core/command/console.py b/src/core/command/console.py index 87c3e9e..21a5ed7 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -85,7 +85,6 @@ class Console(object): else: self.command_parser(" ".join(args[1:])) - # 命令执行总入口 def _console(self): if platform.system() != 'Windows': signal.signal(signal.SIGTSTP, self.handler_ctrl_z) # ctrl+x linux @@ -93,11 +92,9 @@ class Console(object): while True: try: - # 获取用户命令输入 usr_input = input(">>> ") if usr_input == "": continue - # 用户输入命令解析 self.command_parser(usr_input) except SystemExit: LOG.info("Program exit normally!") @@ -105,7 +102,6 @@ class Console(object): except (IOError, EOFError, KeyboardInterrupt) as error: LOG.exception("Input Error: %s" % error) - # 参数解析方法 @classmethod def argument_parser(cls, para_list): """ @@ -117,13 +113,9 @@ class Console(object): parser = None try: - # argparse是一个Python模块:命令行选项、参数和子命令解析器 - # 使用argparse的第一步:创建一个ArgumentParser对象,ArgumentParser对象包含将命令行解析成Python数据类型所需的全部信息 parser = argparse.ArgumentParser(description="Specify test para.") parser.add_argument("action", type=str.lower, help="Specify action") - - # Developer test general test parameters parser.add_argument("-p", "--productform", action="store", type=str.lower, @@ -178,8 +170,6 @@ class Console(object): default="", help="Specify test level" ) - - # Developer test extended test parameters parser.add_argument("-cov", "--coverage", action="store_true", dest="coverage", @@ -214,10 +204,8 @@ class Console(object): default="", help="Specify fuzzer name" ) - # 解析部分命令行参数,会返回一个由两个条目构成的元组,其中包含带成员的命名空间(options)和剩余参数字符串的列表(unparsed) - (options, unparsed) = parser.parse_known_args(para_list) - # Set default value + (options, unparsed) = parser.parse_known_args(para_list) options.target_os_name = "OHOS" options.build_variant = "release" options.device_sn = "" @@ -235,14 +223,12 @@ class Console(object): def command_parser(self, args): try: - # 将用户输入的指令按空格拆分成字符串数组 para_list = args.split() options, _, valid_param = self.argument_parser(para_list) if options is None or not valid_param: LOG.warning("options is None.") return - # 根据命令行的命令选择不同的方法执行 command = options.action if command == "": LOG.warning("action is empty.") @@ -297,7 +283,6 @@ class Console(object): LOG.error("Wrong gen command.") return - # run命令执行入口 @classmethod def _process_command_run(cls, command, options): if command == ToolCommandType.TOOLCMD_KEY_RUN: diff --git a/src/core/command/display.py b/src/core/command/display.py index 5832316..f3fd8f9 100755 --- a/src/core/command/display.py +++ b/src/core/command/display.py @@ -184,20 +184,12 @@ def select_user_input(data_list): return select_item_value, select_item_index -# 选择productform def select_productform(): select_value = "phone" - - # 列表注释 scan_support_product() = [DAYU,Hi3516,ohos_arm64,ohos_sdk,rk3568] scan_product_list = scan_support_product() - - # 从framework_config.xml里取productform节点的value:ipcamera_hispark_aries、ipcamera_hispark_taurus、wifiiot_hispark_pegasus config_product_list = \ FrameworkConfigManager().get_framework_config("productform") - # 列表注释 productform_list = [DAYU,Hi3516,ohos_arm64,ohos_sdk,rk3568, - # 列表注释 ipcamera_hispark_aries、ipcamera_hispark_taurus、wifiiot_hispark_pegasus] - productform_list = scan_product_list + config_product_list if len(productform_list) != 0: print("Please select the current tested product form:") @@ -281,7 +273,6 @@ def show_testtype_list(): print("No category specified.") -# 从OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里的subsystem_infos中subsystem_infos下获取subsystemlist def show_subsystem_list(product_form): print("List of currently supported subsystem names:") parser = ParsePartsConfig(product_form) @@ -306,7 +297,6 @@ def show_acts_subsystem_list(): print("end") -# 从OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里的subsystem_infos中subsystem_infos下获取partlist def show_partname_list(product_form): print("List of currently supported part names:") parser = ParsePartsConfig(product_form) diff --git a/src/core/config/config_manager.py b/src/core/config/config_manager.py index 448d85d..6b41ec7 100755 --- a/src/core/config/config_manager.py +++ b/src/core/config/config_manager.py @@ -24,41 +24,26 @@ from xdevice import platform_logger from core.constants import ConfigFileConst LOG = platform_logger("config_manager") - -# 变量注释 framework_res_dir = OpenHarmony/test/developertest -# 变量注释 CONFIG_PATH = OpenHarmony/test/developertest/config CONFIG_PATH = os.path.join(sys.framework_res_dir, "config") -# framework_config.xml class FrameworkConfigManager(object): - def __init__(self, filepath=""): if filepath == "": - - # 变量注释 filepath = OpenHarmony/test/developertest/config/framework_config.xml self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.FRAMECONFIG_FILEPATH)) else: self.filepath = filepath def get_framework_config(self, target_name): - # 获取framework_config.xml中所有name的value,返回列表 data_list = [] try: if os.path.exists(self.filepath): - - # 读取xml文件 tree = ET.parse(self.filepath) - - # 获取根节点 root = tree.getroot() - - # 获取节点的名字 node = root.find(target_name) - # 遍历 name 节点 获取value 添加到data_list中 for sub in node: value = sub.attrib.get("name") if value and value != "": @@ -67,7 +52,6 @@ class FrameworkConfigManager(object): LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args) return data_list - # 获取framework_config.xml中test_category标签里name、desc、timeout的value,返回字典 def get_test_category_info(self, target_name="test_category"): test_type_timeout_dic = {} try: @@ -87,17 +71,13 @@ class FrameworkConfigManager(object): LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args) return test_type_timeout_dic - # 获取framework_config.xml中all_category标签里name的value,返回列表 如:unittest、moduletest、systemtest、performance def get_all_category_info(self, target_name="all_category"): return self.get_framework_config(target_name) -# filter_config.xml class FilterConfigManager(object): def __init__(self, filepath=""): if filepath == "": - - # 变量注释 filepath = OpenHarmony/test/developertest/config/filter_config.xml self.filepath = os.path.abspath( os.path.join(CONFIG_PATH, ConfigFileConst.FILTERCONFIG_FILEPATH)) @@ -129,7 +109,6 @@ class FilterConfigManager(object): return self.filepath -# 这里的filepath不存在 class ResourceConfigManager(object): def __init__(self, filepath=""): if filepath == "": @@ -165,8 +144,6 @@ class ResourceConfigManager(object): class UserConfigManager(object): def __init__(self, config_file=""): if config_file == "": - - # 变量注释 filepath = OpenHarmony/test/developertest/config/user_config.xml self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.USERCONFIG_FILEPATH)) else: @@ -286,8 +263,6 @@ class UserConfigManager(object): class BuildConfigManager(object): def __init__(self, filepath=""): if filepath == "": - - # 变量注释 filepath = OpenHarmony/test/developertest/config/build_config.xml self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.BUILDCONFIG_FILEPATH)) else: @@ -315,8 +290,6 @@ class BuildConfigManager(object): class FuzzerConfigManager(object): def __init__(self, config_path=""): if config_path == "": - - # 变量注释 filepath = OpenHarmony/test/developertest/config/fuzz_config.xml self.filepath = self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.FUZZCONFIG_FILEPATH)) else: diff --git a/src/core/config/parse_parts_config.py b/src/core/config/parse_parts_config.py index 5a271b7..eac7839 100755 --- a/src/core/config/parse_parts_config.py +++ b/src/core/config/parse_parts_config.py @@ -32,13 +32,10 @@ class ParsePartsConfig(object): self.productform = productform self.subsystem_infos, self.part_infos = self.get_infos_data() - # 获取配置文件地址:~/OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json(以rk3568举例) def get_config_file_path(self): manager = UserConfigManager() - # 获取user_config.xml文件中的配置的(编译好的测试用例地址) testcase_dir = manager.get_test_cases_dir() - # 如果没有在developtertest/config/user_config里配置test_cases路径,就到OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里查找 if testcase_dir == "": if sys.source_code_root_path != "": config_filepath = os.path.join( @@ -47,8 +44,6 @@ class ParsePartsConfig(object): "infos_for_testfwk.json") else: config_filepath = "" - - # 如果在developtertest/config/user_config里配置了test_cases路径,就在这个路径下的infos_for_testfwk.json里查找 else: config_filepath = os.path.join( testcase_dir, @@ -58,7 +53,6 @@ class ParsePartsConfig(object): def get_infos_data(self): config_filepath = self.get_config_file_path() - # 检验给出的路径是否真地存在 if not os.path.exists(config_filepath): print("Error: %s is not exist." % config_filepath) return None, None @@ -70,18 +64,16 @@ class ParsePartsConfig(object): print("Error: json file load error.") return None, None - # open source branch, the part form of all product is "phone" if is_open_source_product(self.productform): product_data_dic = data_dic.get("phone", None) else: product_data_dic = data_dic.get(self.productform, None) - # product_data_dic:infos_for_testfwk.json配置文件中“phone”节点数据 + if product_data_dic is None: print("Error: product_data_dic is None.") return None, None - # subsystem_infos(系统中定义的子系统列表):infos_for_testfwk.json配置文件中“phone”节点下“subsystem_infos”节点数据 + subsystem_infos = product_data_dic.get("subsystem_infos", None) - # subsystem_infos(系统中定义的部件信息列表):infos_for_testfwk.json配置文件中“phone”节点下“part_infos”节点数据 part_infos = product_data_dic.get("part_infos", None) return subsystem_infos, part_infos @@ -98,17 +90,13 @@ class ParsePartsConfig(object): subsystem_name_list.append(item) return subsystem_name_list - # 获取部件列表 def get_part_list(self, subsystemlist, partlist): - # 如果options参数中的partlist不为空,直接返回partlist if len(partlist) != 0: return partlist - # 如果infos_for_testfwk.json配置文件的subsystem_infos为None,返回options参数中的subsystemlist if self.subsystem_infos is None: return subsystemlist part_name_list = [] - # 遍历options参数中的子系统列表,并且将infos_for_testfwk.json配置文件的subsystem_infos中的对应子系统的部件列表加入到part_name_list中 if len(subsystemlist) != 0: for item in subsystemlist: parts = self.subsystem_infos.get(item, []) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 1bec1dd..f15aeca 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -21,12 +21,13 @@ import copy import json import sys from json import JSONDecodeError + +from xdevice import platform_logger from core.utils import get_build_output_path from core.common import is_open_source_product - from core.utils import get_file_list_by_postfix from core.config.config_manager import FilterConfigManager -from xdevice import platform_logger + LOG = platform_logger("TestcaseManager") @@ -85,25 +86,21 @@ class TestCaseManager(object): "subsystem_name", options.productform) filter_list_test_file = FilterConfigManager().get_filtering_list( "testfile_name", options.productform) - # 遍历测试用例输出目录下面的所有文件夹,每个文件夹对应一个子系统 + for part_name in os.listdir(test_case_out_path): 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 - # 获取子系统目录下面的所有文件路径列表 suite_file_list = get_file_list_by_postfix(part_case_dir) for suite_file in suite_file_list: - # 如果文件在resource目录下面,需要过滤 if -1 != suite_file.replace(test_case_out_path, "").find( os.sep + "resource" + os.sep): continue file_name = os.path.basename(suite_file) - # 如果文件在fiter_config.xml配置文件的下面配置过,则过滤 if file_name in filter_list_test_file: continue @@ -135,14 +132,12 @@ class TestCaseManager(object): LOG.info("acts test case path: " + acts_test_case_path) acts_suit_file_dic = copy.deepcopy(TESTFILE_TYPE_DATA_DIC) if os.path.exists(acts_test_case_path): - # 获取acts测试用例输出目录下面的所有文件路径列表 acts_suite_file_list = get_file_list_by_postfix(acts_test_case_path) for acts_suite_file in acts_suite_file_list: file_name = os.path.basename(acts_suite_file) prefix_name, suffix_name = os.path.splitext(file_name) if suffix_name != ".hap": continue - # 如果acts测试指定了-ts,只有完全匹配的HAP包才会加入最终执行的队列 if options.testsuit != "" and options.testsuit != prefix_name: continue if not self.check_hap_test_file(acts_suite_file): diff --git a/src/core/utils.py b/src/core/utils.py index 49a9815..fc0a589 100755 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -50,7 +50,6 @@ def get_file_list(find_path, postfix=""): return file_list -# 获取目录下每一个文件,并放到一个列表里 def get_file_list_by_postfix(path, postfix=""): file_list = [] for dirs in os.walk(path): @@ -97,13 +96,11 @@ def get_build_output_path(product_form): build_output_path = os.path.join(sys.source_code_root_path, "out", build_output_name) - # 返回编译结果输出目录:~/OpenHarmony/out/rk3568(以rk3568举例) return build_output_path def scan_support_product(): # scan standard and large system info - # 路径注释 product_form_dir = OpenHarmony/productdefine/common/products/ product_form_dir = os.path.join(sys.source_code_root_path, "productdefine", "common", diff --git a/src/main/_init_global_config.py b/src/main/_init_global_config.py index 865870b..2d34001 100755 --- a/src/main/_init_global_config.py +++ b/src/main/_init_global_config.py @@ -21,21 +21,12 @@ def _init_global_config(): import sys import os - # insert src path for loading xdevice modules - # 当前脚本运行的绝对路径 去掉最后两个路径 - # 变量注释 framework_src_dir = OpenHarmony/test/developertest sys.framework_src_dir = os.path.abspath(os.path.dirname( os.path.dirname(__file__))) - - # 将目录存放到sys.path模块中,新添加的目录会优先于其他目录被import检查 0代表最高优先级 sys.path.insert(0, sys.framework_src_dir) - - # 当前脚本运行的绝对路径 去掉最后两个路径 - # 变量注释 framework_root_dir = OpenHarmony/test/developertest sys.framework_root_dir = os.path.abspath(os.path.dirname( os.path.dirname(os.path.dirname(__file__)))) - # 变量注释 sys.xdevice_dir = OpenHarmony/test/xdevice/src sys.xdevice_dir = os.path.abspath(os.path.join( sys.framework_root_dir, "..", @@ -43,7 +34,6 @@ def _init_global_config(): "src")) sys.path.insert(0, sys.xdevice_dir) - # 变量注释 sys.xdevice_extension_dir = OpenHarmony/xdevice/extension/src sys.xdevice_extension_dir = os.path.abspath(os.path.join( sys.framework_root_dir, "..", @@ -51,15 +41,12 @@ def _init_global_config(): "extension", "src")) sys.path.insert(1, sys.xdevice_extension_dir) - - # 变量注释 pytest_dir = OpenHarmony/test/developertest/aw/python sys.pytest_dir = os.path.abspath(os.path.join( sys.framework_root_dir, "aw", "python")) sys.path.insert(2, sys.pytest_dir) - # 变量注释 adapter_dir = OpenHarmony/test/developertest/adapter/aw/python sys.adapter_dir = os.path.abspath(os.path.join( sys.framework_root_dir, "adapter" @@ -67,23 +54,18 @@ def _init_global_config(): "python")) sys.path.insert(3, sys.adapter_dir) - # 变量注释 hmh_script = OpenHarmony/test/developertest/libs sys.hmh_script = os.path.abspath(os.path.join( sys.framework_root_dir, "libs")) sys.path.insert(4, sys.hmh_script) - # 变量注释 framework_res_dir = OpenHarmony/test/developertest sys.framework_res_dir = sys.framework_root_dir - - # 变量注释 exec_dir = OpenHarmony/test/developertest sys.exec_dir = sys.framework_root_dir from core.common import get_source_code_root_path sys.source_code_root_path = get_source_code_root_path( sys.framework_root_dir) - # python的参数配置 设置脚本路径 调度python的xdevice from xdevice import Variables Variables.exec_dir = sys.framework_root_dir @@ -92,8 +74,6 @@ def _iter_module_plugins(packages): import importlib import pkgutil for package in packages: - - # 获取__path__对象属性的值,若不存在,默认为“” pkg_path = getattr(package, "__path__", "") pkg_name = getattr(package, "__name__", "") if not pkg_name or not pkg_path: -- Gitee