|
25 | 25 | import re
|
26 | 26 | import logging
|
27 | 27 |
|
28 |
| -BOLD = ("", "") |
| 28 | +# Formatting. Default colors to empty strings. |
| 29 | +BOLD, BLUE, RED, GREY = ("", ""), ("", ""), ("", ""), ("", "") |
| 30 | +TICK = "✓ " |
| 31 | +CROSS = "✖ " |
| 32 | +CIRCLE = "○ " |
29 | 33 | if os.name == 'posix':
|
30 | 34 | # primitive formatting on supported
|
31 | 35 | # terminal via ANSI escape sequences:
|
32 | 36 | BOLD = ('\033[0m', '\033[1m')
|
| 37 | + BLUE = ('\033[0m', '\033[0;34m') |
| 38 | + RED = ('\033[0m', '\033[0;31m') |
| 39 | + GREY = ('\033[0m', '\033[1;30m') |
33 | 40 |
|
34 | 41 | TEST_EXIT_PASSED = 0
|
35 | 42 | TEST_EXIT_SKIPPED = 77
|
@@ -303,7 +310,8 @@ def print_results(test_results, max_len_name, runtime):
|
303 | 310 | test_result.padding = max_len_name
|
304 | 311 | results += str(test_result)
|
305 | 312 |
|
306 |
| - results += BOLD[1] + "\n%s | %s | %s s (accumulated) \n" % ("ALL".ljust(max_len_name), str(all_passed).ljust(7), time_sum) + BOLD[0] |
| 313 | + status = TICK + "Passed" if all_passed else CROSS + "Failed" |
| 314 | + results += BOLD[1] + "\n%s | %s | %s s (accumulated) \n" % ("ALL".ljust(max_len_name), status.ljust(9), time_sum) + BOLD[0] |
307 | 315 | results += "Runtime: %s s\n" % (runtime)
|
308 | 316 | print(results)
|
309 | 317 |
|
@@ -373,26 +381,17 @@ def __init__(self, name, status, time):
|
373 | 381 | self.padding = 0
|
374 | 382 |
|
375 | 383 | def __repr__(self):
|
376 |
| - COLOR = ("", "") |
377 |
| - if os.name == 'posix': |
378 |
| - # primitive formatting on supported |
379 |
| - # terminal via ANSI escape sequences: |
380 |
| - if self.status == "Passed": |
381 |
| - COLOR = ('\033[0m', '\033[0;34m') |
382 |
| - elif self.status == "Failed": |
383 |
| - COLOR = ('\033[0m', '\033[0;31m') |
384 |
| - elif self.status == "Skipped": |
385 |
| - COLOR = ('\033[0m', '\033[1;30m') |
386 |
| - |
387 |
| - SYMBOL = " " |
388 | 384 | if self.status == "Passed":
|
389 |
| - SYMBOL = "✓ " |
| 385 | + color = BLUE |
| 386 | + glyph = TICK |
390 | 387 | elif self.status == "Failed":
|
391 |
| - SYMBOL = "✖ " |
| 388 | + color = RED |
| 389 | + glyph = CROSS |
392 | 390 | elif self.status == "Skipped":
|
393 |
| - SYMBOL = "○ " |
| 391 | + color = GREY |
| 392 | + glyph = CIRCLE |
394 | 393 |
|
395 |
| - return COLOR[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), SYMBOL, self.status.ljust(7), self.time) + COLOR[0] |
| 394 | + return color[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), glyph, self.status.ljust(7), self.time) + color[0] |
396 | 395 |
|
397 | 396 |
|
398 | 397 | def check_script_list(src_dir):
|
|
0 commit comments