From 88af0b3c25ccf97a0195a4baa2ec635f94f63a24 Mon Sep 17 00:00:00 2001 From: bolyor <464861137@qq.com> Date: Wed, 15 Jul 2020 12:06:35 +0800 Subject: [PATCH] [test]add ERRCHECK for test framework --- test/maple_test/test.py | 6 +++--- test/maple_test/utils.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/test/maple_test/test.py b/test/maple_test/test.py index bfa32e6cd0..2c59c34e01 100644 --- a/test/maple_test/test.py +++ b/test/maple_test/test.py @@ -17,9 +17,9 @@ import shlex from functools import total_ordering -from maple_test.utils import PASS, EXEC_FLAG, EXPECT_FLAG, DEPENDENCE_FLAG +from maple_test.utils import PASS, EXEC_FLAG, ERRCHECK_FLAG, EXPECT_FLAG, DEPENDENCE_FLAG from maple_test.utils import read_file -from maple_test.utils import split_comment, filter_line +from maple_test.utils import split_comment, filter_line, filter_command_line from maple_test.utils import FAIL, UNRESOLVED @@ -79,7 +79,7 @@ def extract_commands(comment_lines): flag = False merge_command = "" for command in comment_lines: - command = filter_line(command, EXEC_FLAG) + command = filter_command_line(command) if not command: continue if command.strip()[-1] == "\\": diff --git a/test/maple_test/utils.py b/test/maple_test/utils.py index f4d7c1b4be..51054dbede 100644 --- a/test/maple_test/utils.py +++ b/test/maple_test/utils.py @@ -27,6 +27,7 @@ from functools import wraps from pathlib import Path EXEC_FLAG = "EXEC" +ERRCHECK_FLAG = "ERRCHECK" ASSERT_FLAG = "ASSERT" EXPECT_FLAG = "EXPECT" DEPENDENCE_FLAG = "DEPENDENCE" @@ -138,11 +139,25 @@ def filter_line(line, flag=None): return line line_flag = line.strip().split(":")[0].strip() if line_flag == flag: - new_line = line.strip()[len(flag) + 1 :].strip().lstrip(":").strip() + new_line = line.strip()[len(flag) + 1:].strip().lstrip(":").strip() return new_line return None +def filter_command_line(line): + """Returns and updates the command line starting with the flag""" + line_flag = line.strip().split(":")[0].strip() + new_line = line.strip()[len(line_flag) + 1:].strip().lstrip(":").strip() + if line_flag == EXEC_FLAG: + return new_line + elif line_flag == ERRCHECK_FLAG: + if platform.system() == "Windows": + return new_line + " 2>&1 1>$NUL | compare %f" + else: + return new_line + " 2>&1 1>/dev/null | compare %f" + return None + + def split_comment(comment, lines): """Split text based on comments""" comment_lines = [] -- Gitee