diff --git a/test/maple_test/configs.py b/test/maple_test/configs.py index 14fe51301411e029e10714d11c0d8fa310a544a8..7749b7cc397fcd32bf280d33e111fa5204094df1 100644 --- a/test/maple_test/configs.py +++ b/test/maple_test/configs.py @@ -78,7 +78,8 @@ def parse_args(): default=[], choices=ALL[:], help="Print test cases with specified results, " - "-pPASS -pFAIL, to print all test case that failed or passed", + "-pPASS -pFAIL, to print all test case that failed or passed" + "UNRESOLVED test case results are not displayed by default.", ) test_framework_parser.add_argument( "--progress", @@ -156,7 +157,7 @@ def parse_args(): running_parser.add_argument( "--encoding", action="append", - default=[ENCODING], + default=["UTF-8"], help="Specify the test case encoding format, default encoding is platform " "dependent, but any encoding supported by Python can be passed. " "Can specify multiple encoding formats.", diff --git a/test/maple_test/run.py b/test/maple_test/run.py index 23772843250c521d6314db06d9a00e8da5b065c4..58887c4459e792895cb692db77a628ac8eff0be4 100644 --- a/test/maple_test/run.py +++ b/test/maple_test/run.py @@ -24,7 +24,7 @@ import logging from textwrap import indent, shorten from maple_test.configs import construct_logger, get_val -from maple_test.utils import PASS, FAIL, UNRESOLVED, NOT_RUN, ENCODING +from maple_test.utils import PASS, FAIL, UNRESOLVED, NOT_RUN from maple_test.utils import add_run_path @@ -59,8 +59,8 @@ def run_command(cmd, work_dir, timeout, logger, env=None): return return_code, com_out, com_err else: return_code = process_command.returncode - com_out = com_out.decode(ENCODING, errors="ignore") - com_err = com_err.decode(ENCODING, errors="ignore") + com_out = com_out.decode(sys.stdout.encoding, errors="replace") + com_err = com_err.decode(sys.stderr.encoding, errors="replace") return return_code, com_out, com_err finally: process_command.kill() diff --git a/test/maple_test/task.py b/test/maple_test/task.py index e6d4131499d8408f0f6bcd0a1379fc000edbfdb0..74e74f93cef7b0234e14bc2490aaf16a27384157 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, + DEFAULT_PRINT, OS_SEP, ) from maple_test.utils import ( @@ -285,19 +286,28 @@ class TestSuiteTask: logger.info(line) return self.result[FAIL] - def gen_brief_summary(self): + def gen_brief_summary(self, print_type): total = sum(self.result.values()) + result = copy.deepcopy(self.result) + total -= result.pop(NOT_RUN) + if UNRESOLVED not in print_type: + total -= result.pop(UNRESOLVED) + total_summary = "TestSuiteTask: {}, Total: {}, ".format( self.name, total ) + "".join( [ "{}: {}, ".format(k, v) - for k, v in sort_dict_items(self.result, index=1, reverse=True) + for k, v in sort_dict_items(result, index=1, reverse=True) ] ) task_set_summary = "" for tasks_name in self.task_set: total = sum(self.task_set_result[tasks_name].values()) + task_result = copy.deepcopy(self.task_set_result[tasks_name]) + total -= task_result.pop(NOT_RUN) + if UNRESOLVED not in print_type: + total -= task_result.pop(UNRESOLVED) task_set_summary += ( "\n " + tasks_name @@ -305,9 +315,7 @@ class TestSuiteTask: + "".join( [ "{}: {}, ".format(k, v) - for k, v in sort_dict_items( - self.task_set_result[tasks_name], index=1, reverse=True - ) + for k, v in sort_dict_items(task_result, index=1, reverse=True) ] ) ) @@ -320,13 +328,13 @@ class TestSuiteTask: self.result[status] += num if print_type is None: print_type = configs.get_val("print_type") - brief_summary = self.gen_brief_summary() + brief_summary = self.gen_brief_summary(print_type) summary = "-" * 120 summary += "\nTestSuite Path: {}\n".format(self.path) for tasks_name in self.task_set: for task in sorted(self.task_set[tasks_name], key=lambda task: task.name): result = task.result[0] - if not print_type or task.result[0] in configs.get_val("print_type"): + if result in print_type or (not print_type and result in DEFAULT_PRINT): summary += " {}, Case: {}, Result: {}\n".format( tasks_name, task.case_path, result ) diff --git a/test/maple_test/utils.py b/test/maple_test/utils.py index 14b3a709335434e4ad1e54921ebc6afb60563ff2..782c6645aab630cfd0fee2744f7b904022ed5416 100644 --- a/test/maple_test/utils.py +++ b/test/maple_test/utils.py @@ -35,7 +35,8 @@ NOT_RUN = "NOT_RUN" UNRESOLVED = "UNRESOLVED" UNSUPPORTED = "UNSUPPORTED" UNSUCCESSFUL = [FAIL, UNSUPPORTED, UNRESOLVED, NOT_RUN] -ALL = [PASS, FAIL, XFAIL, XPASS, NOT_RUN, UNRESOLVED, UNSUPPORTED] +ALL = [PASS, FAIL, XFAIL, XPASS, UNSUPPORTED, UNRESOLVED] +DEFAULT_PRINT = [PASS, FAIL, XFAIL, XPASS, UNSUPPORTED] RESULT = { PASS: 0, FAIL: 0,