27
27
import re
28
28
import logging
29
29
30
- # Formatting. Default colors to empty strings.
31
- BOLD , BLUE , RED , GREY = ("" , "" ), ("" , "" ), ("" , "" ), ("" , "" )
30
+ # Formatting.
32
31
try :
33
32
# Make sure python thinks it can write unicode to its stdout
34
33
"\u2713 " .encode ("utf_8" ).decode (sys .stdout .encoding )
40
39
CROSS = "x "
41
40
CIRCLE = "o "
42
41
42
+ # Default colors to empty strings.
43
+ BOLD , BLUE , RED , GREY , MAGENTA = [("" , "" )] * 5
43
44
if os .name == 'posix' :
44
45
# primitive formatting on supported
45
46
# terminal via ANSI escape sequences:
46
47
BOLD = ('\033 [0m' , '\033 [1m' )
47
- BLUE = ('\033 [0m' , '\033 [0;34m' )
48
- RED = ('\033 [0m' , '\033 [0;31m' )
49
48
GREY = ('\033 [0m' , '\033 [1;30m' )
49
+ RED = ('\033 [0m' , '\033 [0;31m' )
50
+ BLUE = ('\033 [0m' , '\033 [0;34m' )
51
+ MAGENTA = ('\033 [0m' , '\033 [0;35m' )
50
52
51
53
TEST_EXIT_PASSED = 0
52
54
TEST_EXIT_SKIPPED = 77
53
55
56
+ STATUS_PASSED = "Passed"
57
+ STATUS_PASSED_WITH_WARNINGS = "Passed with warnings"
58
+ STATUS_SKIPPED = "Skipped"
59
+ STATUS_FAILED = "Failed"
60
+ STATUSES = [STATUS_PASSED , STATUS_PASSED_WITH_WARNINGS , STATUS_SKIPPED , STATUS_FAILED ]
61
+
62
+ STATUS_MAX_LEN = max ([len (st ) for st in STATUSES ])
63
+
54
64
BASE_SCRIPTS = [
55
65
# Scripts that are run by the travis build process.
56
66
# Longest test should go first, to favor running tests in parallel
@@ -306,9 +316,11 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove
306
316
test_result , stdout , stderr = job_queue .get_next ()
307
317
test_results .append (test_result )
308
318
309
- if test_result .status == "Passed" :
319
+ if test_result .status == STATUS_PASSED :
310
320
logging .debug ("\n %s%s%s passed, Duration: %s s" % (BOLD [1 ], test_result .name , BOLD [0 ], test_result .time ))
311
- elif test_result .status == "Skipped" :
321
+ elif test_result .status == STATUS_PASSED_WITH_WARNINGS :
322
+ logging .debug ("\n %s%s%s passed with warnings, Duration: %s s" % (BOLD [1 ], test_result .name , BOLD [0 ], test_result .time ))
323
+ elif test_result .status == STATUS_SKIPPED :
312
324
logging .debug ("\n %s%s%s skipped" % (BOLD [1 ], test_result .name , BOLD [0 ]))
313
325
else :
314
326
print ("\n %s%s%s failed, Duration: %s s\n " % (BOLD [1 ], test_result .name , BOLD [0 ], test_result .time ))
@@ -332,7 +344,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove
332
344
sys .exit (not all_passed )
333
345
334
346
def print_results (test_results , max_len_name , runtime ):
335
- results = "\n " + BOLD [1 ] + "%s | %s | %s\n \n " % ("TEST" .ljust (max_len_name ), "STATUS " , "DURATION" ) + BOLD [0 ]
347
+ results = "\n " + BOLD [1 ] + "%s | %s | %s\n \n " % ("TEST" .ljust (max_len_name ), " STATUS" . ljust ( STATUS_MAX_LEN + 2 ) , "DURATION" ) + BOLD [0 ]
336
348
337
349
test_results .sort (key = lambda result : result .name .lower ())
338
350
all_passed = True
@@ -345,7 +357,7 @@ def print_results(test_results, max_len_name, runtime):
345
357
results += str (test_result )
346
358
347
359
status = TICK + "Passed" if all_passed else CROSS + "Failed"
348
- results += BOLD [1 ] + "\n %s | %s | %s s (accumulated) \n " % ("ALL" .ljust (max_len_name ), status .ljust (9 ), time_sum ) + BOLD [0 ]
360
+ 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 ]
349
361
results += "Runtime: %s s\n " % (runtime )
350
362
print (results )
351
363
@@ -403,11 +415,13 @@ def get_next(self):
403
415
[stdout , stderr ] = [l .read ().decode ('utf-8' ) for l in (log_out , log_err )]
404
416
log_out .close (), log_err .close ()
405
417
if proc .returncode == TEST_EXIT_PASSED and stderr == "" :
406
- status = "Passed"
418
+ status = STATUS_PASSED
419
+ elif proc .returncode == TEST_EXIT_PASSED :
420
+ status = STATUS_PASSED_WITH_WARNINGS
407
421
elif proc .returncode == TEST_EXIT_SKIPPED :
408
- status = "Skipped"
422
+ status = STATUS_SKIPPED
409
423
else :
410
- status = "Failed"
424
+ status = STATUS_FAILED
411
425
self .num_running -= 1
412
426
self .jobs .remove (j )
413
427
@@ -422,17 +436,20 @@ def __init__(self, name, status, time):
422
436
self .padding = 0
423
437
424
438
def __repr__ (self ):
425
- if self .status == "Passed" :
439
+ if self .status == STATUS_PASSED :
426
440
color = BLUE
427
441
glyph = TICK
428
- elif self .status == "Failed" :
429
- color = RED
430
- glyph = CROSS
431
- elif self .status == "Skipped" :
442
+ if self .status == STATUS_PASSED_WITH_WARNINGS :
443
+ color = MAGENTA
444
+ glyph = TICK
445
+ elif self .status == STATUS_SKIPPED :
432
446
color = GREY
433
447
glyph = CIRCLE
448
+ elif self .status == STATUS_FAILED :
449
+ color = RED
450
+ glyph = CROSS
434
451
435
- return color [1 ] + "%s | %s%s | %s s\n " % (self .name .ljust (self .padding ), glyph , self .status .ljust (7 ), self .time ) + color [0 ]
452
+ 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 ]
436
453
437
454
@property
438
455
def was_successful (self ):
0 commit comments