Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions test/parallel_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import common
from common import errlog

from tools.diagnostics import with_color, CYAN, GREEN, RED
from tools.utils import WINDOWS


Expand Down Expand Up @@ -304,35 +305,41 @@ def compute_progress(self):
with self.lock:
val = f'[{int(self.progress_counter.value * 100 / self.num_tests)}%] '
self.progress_counter.value += 1
return val
return with_color(CYAN, val)

def addSuccess(self, test):
errlog(f'{self.compute_progress()}{test} ... ok ({self.calculateElapsed():.2f}s)')
msg = f'ok ({self.calculateElapsed():.2f}s)'
errlog(f'{self.compute_progress()}{test} ... {with_color(GREEN, msg)}')
self.buffered_result = BufferedTestSuccess(test)
self.test_result = 'success'

def addExpectedFailure(self, test, err):
errlog(f'{self.compute_progress()}{test} ... expected failure ({self.calculateElapsed():.2f}s)')
msg = f'expected failure ({self.calculateElapsed():.2f}s)'
errlog(f'{self.compute_progress()}{test} ... {with_color(RED, msg)}')
self.buffered_result = BufferedTestExpectedFailure(test, err)
self.test_result = 'expected failure'

def addUnexpectedSuccess(self, test):
errlog(f'{self.compute_progress()}{test} ... unexpected success ({self.calculateElapsed():.2f}s)')
msg = f'unexpected success ({self.calculateElapsed():.2f}s)'
errlog(f'{self.compute_progress()}{test} ... {with_color(RED, msg)}')
self.buffered_result = BufferedTestUnexpectedSuccess(test)
self.test_result = 'unexpected success'

def addSkip(self, test, reason):
errlog(f"{self.compute_progress()}{test} ... skipped '{reason}'")
msg = f"skipped '{reason}'"
errlog(f"{self.compute_progress()}{test} ... {with_color(CYAN, msg)}")
self.buffered_result = BufferedTestSkip(test, reason)
self.test_result = 'skipped'

def addFailure(self, test, err):
errlog(f'{self.compute_progress()}{test} ... FAIL')
msg = f'{test} ... FAIL'
errlog(f'{self.compute_progress()}{with_color(RED, msg)}')
self.buffered_result = BufferedTestFailure(test, err)
self.test_result = 'failed'

def addError(self, test, err):
errlog(f'{self.compute_progress()}{test} ... ERROR')
msg = f'{test} ... ERROR'
errlog(f'{self.compute_progress()}{with_color(RED, msg)}')
self.buffered_result = BufferedTestError(test, err)
self.test_result = 'errored'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this work for -j1 too? i.e. the non-parallel runner? Maybe as a followup? Maybe the default python runner already has some color support?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be nice (also to add the [35%] progress bar), though looks more difficult, since in non-parallel runner the printing is handled by the built-in TextTestResult class, which I don't know how to replace.

Another thing I'd want to do is remove the long wall of test results dump at the very end of the test run, which repeats the same results from the test run a second time.. that is a bit spammy.


Expand Down
4 changes: 4 additions & 0 deletions tools/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def reset_color():
return '\033[0m'


def with_color(color, text):
return output_color(color) + text + reset_color()


def diag(level, msg, *args):
# Format output message as:
# <tool>: <level>: msg
Expand Down
Loading