def _form_task_set(self, running_config, cli_running_config): logger = configs.LOGGER user_test_list = cli_running_config.get("test_list") user_config_set = cli_running_config.get("user_config_set") user_config = cli_running_config.get("user_config") user_env = cli_running_config.get("user_env") raw_top_config = read_config(self.cfg_path) top_config = TaskConfig(self.cfg_path, raw_top_config, None, user_config, user_env) top_dir = top_config.base_dir if user_test_list is None: top_testlist_path = self._get_testlist(raw_top_config, top_dir) else: top_testlist_path = top_dir / user_test_list if user_config_set: run_config_set = user_config_set else: run_config_set = list(top_dir.glob("**/*.cfg")) for cfg in run_config_set: if not cfg.exists(): logger.error( "Error: cfg file: {} not found, will skip".format(cfg)) continue try: raw_config = read_config(cfg) except: logger.error( "The found configuration file {} has an error and will " "skip the test configuration file, please modify the " "configuration file or ignore the message. ".format(cfg)) continue config = TaskConfig(cfg, raw_config, top_config, user_config, user_env) name = config.name base_dir = config.base_dir if cfg == self.cfg_path: testlist_path = top_testlist_path else: testlist_path = self._get_testlist(raw_config, base_dir) self.task_set_result[name] = OrderedDict({ PASS: 0, FAIL: 0, NOT_RUN: 0, UNRESOLVED: 0 }) for case in self._search_list(base_dir, testlist_path): task = SingleTask(case, config, running_config) self.task_set[name].append(task) self.task_set_result[name][task.result[0]] += 1 if sum([len(case) for case in self.task_set.values()]) < 1: logger.info( "Path %s not in testlist, be sure add path to testlist", str(self.path), )
def parser_maple_test_config_file(maple_test_cfg_file): raw_config = read_config(maple_test_cfg_file) test_paths = get_config_value(raw_config, "test-home", "dir") if test_paths: test_paths = test_paths.replace("\n", "").split(":") else: test_paths = [] test_suite_config = { "test_paths": [complete_path(BASE_DIR / path) for path in test_paths if path], } log_config = { "dir": complete_path(BASE_DIR / Path(get_config_value(raw_config, "logging", "name"))), "level": get_level_name(get_config_value(raw_config, "logging", "level")), } running_config = { "temp_dir": complete_path( BASE_DIR / Path(get_config_value(raw_config, "running", "temp_dir"))), } return test_suite_config, running_config, log_config
def __init__(self, test_path, cfg_path, running_config, cli_running_config=None): if cli_running_config is None: cli_running_config = {} self.path = complete_path(test_path) self.cfg_path = cfg_path config = read_config(self.cfg_path) if config is None: raise TestError( "Test suite config path:{} not found, skip!!!!!".format( self.cfg_path)) try: self.name = config["description"]["title"].replace(" ", "") except KeyError: self.name = self.path.name self.suffix_comments = config_section_to_dict(config, "suffix") self.result = defaultdict(int) self.config_set = {} self.testlist_set = {} self.task_set = defaultdict(list) self.task_set_result = {} self.all_cases = {} self._form_task_set(running_config, cli_running_config)