mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
ci/lava: Don't print empty lines when changing sections
Make `print_log` section-aware to stop printing newlines whenever a section changes. This also caught a bug: the `handle_exception` was sending an exception type to the `print_log`, now it is fixed. Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33906>
This commit is contained in:
parent
422e65557d
commit
8fcc52b8d7
3 changed files with 11 additions and 4 deletions
|
|
@ -83,11 +83,13 @@ class GitlabSection:
|
|||
)
|
||||
|
||||
def __enter__(self):
|
||||
print(self.start())
|
||||
if start_log_line := self.start():
|
||||
print(start_log_line)
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
print(self.end())
|
||||
if end_log_line := self.end():
|
||||
print(end_log_line)
|
||||
|
||||
def start(self) -> str:
|
||||
assert not self.has_finished, "Starting an already finished section"
|
||||
|
|
|
|||
|
|
@ -182,7 +182,8 @@ class LAVAJob:
|
|||
return lava_lines[:last_line]
|
||||
|
||||
def handle_exception(self, exception: Exception):
|
||||
print_log(exception)
|
||||
# Print the exception type and message
|
||||
print_log(f"{type(exception).__name__}: {str(exception)}")
|
||||
self.cancel()
|
||||
self.exception = exception
|
||||
|
||||
|
|
|
|||
|
|
@ -305,8 +305,12 @@ def fix_lava_gitlab_section_log():
|
|||
yield first_line
|
||||
|
||||
|
||||
|
||||
def print_log(msg: str, *args) -> None:
|
||||
is_section_header = msg.startswith("\x1b[0Ksection_")
|
||||
if is_section_header:
|
||||
print(msg, *args)
|
||||
return
|
||||
|
||||
# Reset color from timestamp, since `msg` can tint the terminal color
|
||||
ts = datetime.now(tz=UTC)
|
||||
ts_str = f"{ts.hour:02}:{ts.minute:02}:{ts.second:02}.{int(ts.microsecond / 1000):03}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue