Skip to content

Commit 60f9778

Browse files
committed
Revert "[tests] Allow tests to pass when stderr is non-empty"
This reverts commit d64ac3f after further discussion. Tree-SHA512: db1e4ff5b17bcd6fd000a3d21aa74f6b7e4c194e0663c1896a100612671910a7cdadd896b59642420ea016598895b54a8468914847ebefef105a3c47c311d4b2
1 parent f1f1605 commit 60f9778

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

test/functional/test_runner.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
import re
2828
import logging
2929

30-
# Formatting.
30+
# Formatting. Default colors to empty strings.
31+
BOLD, BLUE, RED, GREY = ("", ""), ("", ""), ("", ""), ("", "")
3132
try:
3233
# Make sure python thinks it can write unicode to its stdout
3334
"\u2713".encode("utf_8").decode(sys.stdout.encoding)
@@ -39,28 +40,17 @@
3940
CROSS = "x "
4041
CIRCLE = "o "
4142

42-
# Default colors to empty strings.
43-
BOLD, BLUE, RED, GREY, MAGENTA = [("", "")] * 5
4443
if os.name == 'posix':
4544
# primitive formatting on supported
4645
# terminal via ANSI escape sequences:
4746
BOLD = ('\033[0m', '\033[1m')
48-
GREY = ('\033[0m', '\033[1;30m')
49-
RED = ('\033[0m', '\033[0;31m')
5047
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')
5250

5351
TEST_EXIT_PASSED = 0
5452
TEST_EXIT_SKIPPED = 77
5553

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-
6454
BASE_SCRIPTS= [
6555
# Scripts that are run by the travis build process.
6656
# 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
317307
test_result, stdout, stderr = job_queue.get_next()
318308
test_results.append(test_result)
319309

320-
if test_result.status == STATUS_PASSED:
310+
if test_result.status == "Passed":
321311
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":
325313
logging.debug("\n%s%s%s skipped" % (BOLD[1], test_result.name, BOLD[0]))
326314
else:
327315
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
345333
sys.exit(not all_passed)
346334

347335
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]
349337

350338
test_results.sort(key=lambda result: result.name.lower())
351339
all_passed = True
@@ -358,7 +346,7 @@ def print_results(test_results, max_len_name, runtime):
358346
results += str(test_result)
359347

360348
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]
362350
results += "Runtime: %s s\n" % (runtime)
363351
print(results)
364352

@@ -416,13 +404,11 @@ def get_next(self):
416404
[stdout, stderr] = [l.read().decode('utf-8') for l in (log_out, log_err)]
417405
log_out.close(), log_err.close()
418406
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"
422408
elif proc.returncode == TEST_EXIT_SKIPPED:
423-
status = STATUS_SKIPPED
409+
status = "Skipped"
424410
else:
425-
status = STATUS_FAILED
411+
status = "Failed"
426412
self.num_running -= 1
427413
self.jobs.remove(j)
428414

@@ -437,20 +423,17 @@ def __init__(self, name, status, time):
437423
self.padding = 0
438424

439425
def __repr__(self):
440-
if self.status == STATUS_PASSED:
426+
if self.status == "Passed":
441427
color = BLUE
442428
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":
450430
color = RED
451431
glyph = CROSS
432+
elif self.status == "Skipped":
433+
color = GREY
434+
glyph = CIRCLE
452435

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]
454437

455438
@property
456439
def was_successful(self):

0 commit comments

Comments
 (0)