Skip to content

Commit e406e04

Browse files
committed
Include log file in CI test results
1 parent 1d7835a commit e406e04

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

testsuite/drivers/pylsp.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import json
77
import logging
88
import os
9-
import psutil
9+
import re
1010
import shlex
1111
import sys
1212
import urllib
@@ -19,6 +19,7 @@
1919
import attrs
2020
import lsprotocol.converters
2121
import lsprotocol.types
22+
import psutil
2223
from drivers import ALSTestDriver
2324
from e3.os.process import Run, command_line_image
2425
from e3.testsuite.driver.classic import ProcessResult, TestAbortWithFailure
@@ -700,6 +701,24 @@ async def async_wrapper(
700701
if assert_no_lsp_errors:
701702
# Assert the absence of Error LSP log messages
702703
client.assertNoLSPErrors()
704+
except Exception:
705+
# In case of test failure in CI, include the ALS log file
706+
if "CI" in os.environ and client:
707+
LOG_FILE_PATTERN = r"Log file is: (.*)"
708+
log_file_message = [
709+
m
710+
for m in client.log_messages
711+
if re.search(LOG_FILE_PATTERN, m.message)
712+
]
713+
if log_file_message:
714+
m = re.search(LOG_FILE_PATTERN, log_file_message[0].message)
715+
if m:
716+
log_path = Path(m.group(1))
717+
LOG.info(
718+
"Content of log file %s:\n%s",
719+
log_path,
720+
log_path.read_text(),
721+
)
703722
finally:
704723
try:
705724
if client:

0 commit comments

Comments
 (0)