From fe77c504defa7541cc08e44fd5a06c0ff256b140 Mon Sep 17 00:00:00 2001 From: XiaGuochao Date: Wed, 22 Apr 2020 14:43:31 +0800 Subject: [PATCH] use os.path.sep for path separator --- test/maple_test/compare.py | 4 ++-- test/maple_test/task.py | 7 ++++--- test/maple_test/utils.py | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/maple_test/compare.py b/test/maple_test/compare.py index b63206acb7..a2f9c2ef98 100644 --- a/test/maple_test/compare.py +++ b/test/maple_test/compare.py @@ -171,7 +171,7 @@ def is_valid_pattern(pattern): def regex_match(content, line_map, pattern, start=0): - pattern = r"\s*".join([word for word in pattern.split()]) + pattern = r"\s+".join([word for word in pattern.split()]) matches = re.finditer(str(pattern), content, re.MULTILINE) end = 0 for _, match in enumerate(matches, start=1): @@ -279,7 +279,7 @@ def extract_compare_lines(file_path, regex): def parse_cli(): - parser = argparse.ArgumentParser(prog="compare") + parser = argparse.ArgumentParser(prog="compare.py") parser.add_argument("--comment", help="Test case comment") parser.add_argument( "--assert_flag", diff --git a/test/maple_test/task.py b/test/maple_test/task.py index da482f23e7..e6d4131499 100644 --- a/test/maple_test/task.py +++ b/test/maple_test/task.py @@ -32,6 +32,7 @@ from maple_test.utils import ( FAIL, NOT_RUN, UNRESOLVED, + OS_SEP, ) from maple_test.utils import ( read_config, @@ -52,7 +53,7 @@ class TaskConfig: self.suffix_comments = {} else: self.inherit_top_config(top_config) - name = str(path.relative_to(top_config.path.parent)).replace("/", "_") + name = str(path.relative_to(top_config.path.parent)).replace(OS_SEP, "_") self.name = name.replace(".", "_") self.path = complete_path(path) self.base_dir = self.path.parent @@ -169,7 +170,7 @@ class TestSuiteTask: base_dir = config.base_dir testlist = self._get_testlist(raw_config, base_dir, encoding) self.task_set_result[name] = OrderedDict( - {"PASS": 0, "FAIL": 0, "NOT_RUN": 0, "UNRESOLVED": 0} + {PASS: 0, FAIL: 0, NOT_RUN: 0, UNRESOLVED: 0} ) for case in self._search_list(base_dir, testlist, encoding): task = SingleTask(case, config, running_config) @@ -282,7 +283,7 @@ class TestSuiteTask: print_type = configs.get_val("print_type") for line in self.gen_summary(print_type).splitlines(): logger.info(line) - return self.result["FAIL"] + return self.result[FAIL] def gen_brief_summary(self): total = sum(self.result.values()) diff --git a/test/maple_test/utils.py b/test/maple_test/utils.py index bf2d54a840..14b3a70933 100644 --- a/test/maple_test/utils.py +++ b/test/maple_test/utils.py @@ -47,6 +47,7 @@ RESULT = { BASE_DIR = Path(__file__).parent.absolute() ENCODING = locale.getdefaultlocale()[1] if locale.getdefaultlocale()[1] else "UTF-8" +OS_SEP = os.path.sep EXECUTABLE = sys.executable COMPARE = BASE_DIR / "compare.py" -- Gitee