mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
ci(micropython): improve logs (#6257)
This commit is contained in:
parent
93a9190dd8
commit
01749e0687
@ -36,6 +36,15 @@ DEBUG = 0
|
||||
|
||||
debug_log = None
|
||||
|
||||
saved_test_data = []
|
||||
|
||||
|
||||
def format_error_data(data):
|
||||
output = ''
|
||||
for line in data.split('\n'):
|
||||
output += f'\033[31;1m{line}\033[0m\n'
|
||||
return output
|
||||
|
||||
|
||||
def log(*args):
|
||||
args = ' '.join(repr(arg) for arg in args)
|
||||
@ -109,23 +118,34 @@ class MicroPython_Test(unittest.TestCase):
|
||||
logged = True
|
||||
log('--->', micropy_data)
|
||||
|
||||
if micropy_data.endswith(b'\nERROR END\n'):
|
||||
if b'\nERROR END\n' in micropy_data:
|
||||
error_data = micropy_data.split(b'\nERROR START\n')[-1].split(b'\nERROR END\n')[0]
|
||||
micropy_data = b''
|
||||
log('---> ERROR: ', error_data)
|
||||
try:
|
||||
log('---> ERROR: ', error_data.decode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
log('---> ERROR: ', error_data)
|
||||
|
||||
logged = True
|
||||
break
|
||||
|
||||
if not logged:
|
||||
log('--->', micropy_data)
|
||||
|
||||
if b'\nERROR END\n' in micropy_data:
|
||||
error_data = micropy_data.split(b'\nERROR START\n')[-1].split(b'\nERROR END\n')[0]
|
||||
micropy_data = b''
|
||||
try:
|
||||
log('---> ERROR: ', error_data.decode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
log('---> ERROR: ', error_data)
|
||||
|
||||
if cls.exit_event.is_set():
|
||||
log('--EXIT EVENT SET')
|
||||
|
||||
if micropy_data:
|
||||
return micropy_data.replace(marker, b''), error_data
|
||||
saved_test_data.append((micropy_data, error_data))
|
||||
|
||||
return micropy_data, error_data
|
||||
return micropy_data.replace(marker, b''), error_data
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@ -312,6 +332,21 @@ class MicroPython_Test(unittest.TestCase):
|
||||
for item in sublist
|
||||
])))
|
||||
|
||||
except binascii.Error:
|
||||
error = []
|
||||
for line, err in saved_test_data:
|
||||
if err:
|
||||
try:
|
||||
error.append(err.decode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
error.append(str(err))
|
||||
|
||||
error = '\n'.join(error)
|
||||
if error:
|
||||
self.fail(format_error_data(error))
|
||||
else:
|
||||
self.fail(b'\n'.join(test_data.result))
|
||||
|
||||
except: # NOQA
|
||||
import traceback
|
||||
|
||||
|
@ -165,7 +165,7 @@ def create_ui():
|
||||
lv.GRID_ALIGN.CENTER,
|
||||
0,
|
||||
1
|
||||
)
|
||||
)
|
||||
|
||||
# Bind to a subject
|
||||
dropdown.bind_value(chart_type_subject)
|
||||
|
Loading…
x
Reference in New Issue
Block a user