diff options
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/test_runner.py | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 92c95b1b8f..a043560ea8 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -27,7 +27,8 @@ import tempfile import re import logging -# Formatting. +# Formatting. Default colors to empty strings. +BOLD, BLUE, RED, GREY = ("", ""), ("", ""), ("", ""), ("", "") try: # Make sure python thinks it can write unicode to its stdout "\u2713".encode("utf_8").decode(sys.stdout.encoding) @@ -39,28 +40,17 @@ except UnicodeDecodeError: CROSS = "x " CIRCLE = "o " -# Default colors to empty strings. -BOLD, BLUE, RED, GREY, MAGENTA = [("", "")] * 5 if os.name == 'posix': # primitive formatting on supported # terminal via ANSI escape sequences: BOLD = ('\033[0m', '\033[1m') - GREY = ('\033[0m', '\033[1;30m') - RED = ('\033[0m', '\033[0;31m') BLUE = ('\033[0m', '\033[0;34m') - MAGENTA = ('\033[0m', '\033[0;35m') + RED = ('\033[0m', '\033[0;31m') + GREY = ('\033[0m', '\033[1;30m') TEST_EXIT_PASSED = 0 TEST_EXIT_SKIPPED = 77 -STATUS_PASSED = "Passed" -STATUS_PASSED_WITH_WARNINGS = "Passed with warnings" -STATUS_SKIPPED = "Skipped" -STATUS_FAILED = "Failed" -STATUSES = [STATUS_PASSED, STATUS_PASSED_WITH_WARNINGS, STATUS_SKIPPED, STATUS_FAILED] - -STATUS_MAX_LEN = max([len(st) for st in STATUSES]) - BASE_SCRIPTS= [ # Scripts that are run by the travis build process. # Longest test should go first, to favor running tests in parallel @@ -317,11 +307,9 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove test_result, stdout, stderr = job_queue.get_next() test_results.append(test_result) - if test_result.status == STATUS_PASSED: + if test_result.status == "Passed": logging.debug("\n%s%s%s passed, Duration: %s s" % (BOLD[1], test_result.name, BOLD[0], test_result.time)) - elif test_result.status == STATUS_PASSED_WITH_WARNINGS: - logging.debug("\n%s%s%s passed with warnings, Duration: %s s" % (BOLD[1], test_result.name, BOLD[0], test_result.time)) - elif test_result.status == STATUS_SKIPPED: + elif test_result.status == "Skipped": logging.debug("\n%s%s%s skipped" % (BOLD[1], test_result.name, BOLD[0])) else: print("\n%s%s%s failed, Duration: %s s\n" % (BOLD[1], test_result.name, BOLD[0], test_result.time)) @@ -345,7 +333,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove sys.exit(not all_passed) def print_results(test_results, max_len_name, runtime): - results = "\n" + BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), " STATUS".ljust(STATUS_MAX_LEN + 2), "DURATION") + BOLD[0] + results = "\n" + BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "STATUS ", "DURATION") + BOLD[0] test_results.sort(key=lambda result: result.name.lower()) all_passed = True @@ -358,7 +346,7 @@ def print_results(test_results, max_len_name, runtime): results += str(test_result) status = TICK + "Passed" if all_passed else CROSS + "Failed" - results += BOLD[1] + "\n%s | %s | %s s (accumulated) \n" % ("ALL".ljust(max_len_name), status.ljust(STATUS_MAX_LEN + 2), time_sum) + BOLD[0] + results += BOLD[1] + "\n%s | %s | %s s (accumulated) \n" % ("ALL".ljust(max_len_name), status.ljust(9), time_sum) + BOLD[0] results += "Runtime: %s s\n" % (runtime) print(results) @@ -416,13 +404,11 @@ class TestHandler: [stdout, stderr] = [l.read().decode('utf-8') for l in (log_out, log_err)] log_out.close(), log_err.close() if proc.returncode == TEST_EXIT_PASSED and stderr == "": - status = STATUS_PASSED - elif proc.returncode == TEST_EXIT_PASSED: - status = STATUS_PASSED_WITH_WARNINGS + status = "Passed" elif proc.returncode == TEST_EXIT_SKIPPED: - status = STATUS_SKIPPED + status = "Skipped" else: - status = STATUS_FAILED + status = "Failed" self.num_running -= 1 self.jobs.remove(j) @@ -437,20 +423,17 @@ class TestResult(): self.padding = 0 def __repr__(self): - if self.status == STATUS_PASSED: + if self.status == "Passed": color = BLUE glyph = TICK - if self.status == STATUS_PASSED_WITH_WARNINGS: - color = MAGENTA - glyph = TICK - elif self.status == STATUS_SKIPPED: - color = GREY - glyph = CIRCLE - elif self.status == STATUS_FAILED: + elif self.status == "Failed": color = RED glyph = CROSS + elif self.status == "Skipped": + color = GREY + glyph = CIRCLE - return color[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), glyph, self.status.ljust(STATUS_MAX_LEN), self.time) + color[0] + return color[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), glyph, self.status.ljust(7), self.time) + color[0] @property def was_successful(self): |