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