def _search_list(self, base_dir, testlist, encoding): logger = configs.LOGGER suffixes = self.suffix_comments.keys() include, exclude = testlist case_files = set() cases = [] case_files = self._search_case(include, exclude, base_dir, suffixes) if self.path.is_file(): case_files = [self.path] else: case_files = [ file.relative_to(self.path) for file in case_files if is_relative(file, self.path) ] for case_file in case_files: case_name = str(case_file).replace(".", "_") comment = self.suffix_comments[case_file.suffix[1:]] if case_name not in self.all_cases: case = Case( case_file, self.path, comment, encoding, ) self.all_cases[case_name] = case cases.append(self.all_cases[case_name])
def init_config(): global TEST_CONFIG ( TEST_CONFIG, cli_test_suite_config, cli_running_config, cli_log_config, ) = parse_args() ( file_test_suite_config, file_running_config, file_log_config, ) = parser_maple_test_config_file(TEST_CONFIG.get("cfg")) cli_test_paths = cli_test_suite_config.get("test_paths") or [] file_test_paths = file_test_suite_config.get("test_paths") or [] for path1 in cli_test_paths: for path2 in file_test_paths: if is_relative(path1, path2): user_test_cfg = cli_test_suite_config.get("test_cfg") if not user_test_cfg: cli_test_suite_config["test_cfg"] = complete_path( path2 / "test.cfg") test_suite_config = merge_config(cli_test_suite_config, file_test_suite_config) running_config = merge_config(cli_running_config, file_running_config) log_config = merge_config(cli_log_config, file_log_config) if log_config.get("dir") is None: log_dir = complete_path(Path("./maple_test_log")) print( "No log dir find in cfg file and cli args, will create lod gir at: {}" .format(log_dir)) log_config["dir"] = log_dir global CASE_ENCODING CASE_ENCODING = TEST_CONFIG.get("encoding") global LOGGER maple_test_log_config = log_config.copy() maple_test_log_config["verbose"] = True maple_test_log_config["level"] = min(20, maple_test_log_config.get("level")) stream_fmt = logging.Formatter("%(message)s") log_dir = maple_test_log_config.get("dir") if not log_dir.exists(): log_dir.mkdir(parents=True, exist_ok=True) LOGGER = construct_logger( maple_test_log_config, "Maple_Test", stream_fmt=stream_fmt, stream_level=min(20, maple_test_log_config.get("level")), ) LOGGER.info("Test log saved to {}".format(log_dir)) running_config["log_config"] = log_config.copy() return test_suite_config, running_config, log_config
def _search_list(self, base_dir, testlist_path): logger = configs.LOGGER suffixes = self.suffix_comments.keys() include, exclude = read_list(testlist_path) case_files = set() cases = [] all_test_case, exclude_test_case = self._search_case( include, exclude, base_dir, suffixes) case_files = set() for pattern in all_test_case: _cases = all_test_case[pattern] if _cases: case_files.update(_cases) else: logger.info( "Testlist: {}, ALL-TEST-CASE: {} is contain not test case". format(testlist_path, pattern)) for pattern in exclude_test_case: _cases = exclude_test_case[pattern] if _cases: case_files -= _cases else: logger.info( "Testlist: {}, EXCLUDE-TEST-CASE: {} is contain not test case" .format(testlist_path, pattern)) if self.path.is_file(): case_files = [self.path] else: case_files = [ file.relative_to(self.path) for file in case_files if is_relative(file, self.path) ] for case_file in case_files: case_name = str(case_file).replace(".", "_") comment = self.suffix_comments[case_file.suffix[1:]] if case_name not in self.all_cases: case = Case( case_file, self.path, comment, ) self.all_cases[case_name] = case cases.append(self.all_cases[case_name])