mtest: add an ASCII-only version of the spinner

While the horizontal line and the other pictograms in mtest have an ASCII-only
version, the spinner does not.  This causes mtest to fail with a
UnicodeEncodeError exception on non-Unicode locales.

Fixes: #9538
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/9667/head
Paolo Bonzini 3 years ago committed by Nirbheek Chauhan
parent bc3a55743a
commit 0d139c6e79
  1. 11
      mesonbuild/mtest.py

@ -477,8 +477,9 @@ class TestFileLogger(TestLogger):
class ConsoleLogger(TestLogger): class ConsoleLogger(TestLogger):
SPINNER = "\U0001f311\U0001f312\U0001f313\U0001f314" + \ ASCII_SPINNER = ['..', ':.', '.:']
"\U0001f315\U0001f316\U0001f317\U0001f318" SPINNER = ["\U0001f311", "\U0001f312", "\U0001f313", "\U0001f314",
"\U0001f315", "\U0001f316", "\U0001f317", "\U0001f318"]
SCISSORS = "\u2700 " SCISSORS = "\u2700 "
HLINE = "\u2015" HLINE = "\u2015"
@ -506,12 +507,14 @@ class ConsoleLogger(TestLogger):
self.output_start = dashes(self.SCISSORS, self.HLINE, self.cols - 2) self.output_start = dashes(self.SCISSORS, self.HLINE, self.cols - 2)
self.output_end = dashes('', self.HLINE, self.cols - 2) self.output_end = dashes('', self.HLINE, self.cols - 2)
self.sub = self.RTRI self.sub = self.RTRI
self.spinner = self.SPINNER
try: try:
self.output_start.encode(sys.stdout.encoding or 'ascii') self.output_start.encode(sys.stdout.encoding or 'ascii')
except UnicodeEncodeError: except UnicodeEncodeError:
self.output_start = dashes('8<', '-', self.cols - 2) self.output_start = dashes('8<', '-', self.cols - 2)
self.output_end = dashes('', '-', self.cols - 2) self.output_end = dashes('', '-', self.cols - 2)
self.sub = '| ' self.sub = '| '
self.spinner = self.ASCII_SPINNER
def flush(self) -> None: def flush(self) -> None:
if self.should_erase_line: if self.should_erase_line:
@ -536,8 +539,8 @@ class ConsoleLogger(TestLogger):
count = '{}-{}/{}'.format(self.started_tests - len(self.running_tests) + 1, count = '{}-{}/{}'.format(self.started_tests - len(self.running_tests) + 1,
self.started_tests, self.test_count) self.started_tests, self.test_count)
left = '[{}] {} '.format(count, self.SPINNER[self.spinner_index]) left = '[{}] {} '.format(count, self.spinner[self.spinner_index])
self.spinner_index = (self.spinner_index + 1) % len(self.SPINNER) self.spinner_index = (self.spinner_index + 1) % len(self.spinner)
right = '{spaces} {dur:{durlen}}'.format( right = '{spaces} {dur:{durlen}}'.format(
spaces=' ' * TestResult.maxlen(), spaces=' ' * TestResult.maxlen(),

Loading…
Cancel
Save