mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Merge pull request #21160 from owen-mc/scripts/accept-ci-changes-more-robust
Scripts: be more robust when parsing test logs
This commit is contained in:
@@ -103,33 +103,37 @@ def make_patches_from_log_file(log_file_lines) -> List[Patch]:
|
||||
line = parse_log_line(raw_line)
|
||||
|
||||
if line == "--- expected":
|
||||
while True:
|
||||
next_line = parse_log_line(next(lines))
|
||||
if next_line == "+++ actual":
|
||||
break
|
||||
try:
|
||||
while True:
|
||||
next_line = parse_log_line(next(lines))
|
||||
if next_line == "+++ actual":
|
||||
break
|
||||
|
||||
lines_changed = []
|
||||
lines_changed = []
|
||||
|
||||
while True:
|
||||
next_line = parse_log_line(next(lines))
|
||||
# it can be the case that
|
||||
if next_line and next_line[0] in (" ", "-", "+", "@"):
|
||||
lines_changed.append(next_line)
|
||||
if "FAILED" in next_line:
|
||||
break
|
||||
while True:
|
||||
next_line = parse_log_line(next(lines))
|
||||
# it can be the case that
|
||||
if next_line and next_line[0] in (" ", "-", "+", "@"):
|
||||
lines_changed.append(next_line)
|
||||
if "FAILED" in next_line:
|
||||
break
|
||||
|
||||
# error line _should_ be next, but sometimes the output gets interleaved...
|
||||
# so we just skip until we find the error line
|
||||
error_line = next_line
|
||||
while True:
|
||||
# internal
|
||||
filename_match = re.fullmatch(r"^##\[error\].*FAILED\(RESULT\) (.*)$", error_line)
|
||||
if not filename_match:
|
||||
# codeql action
|
||||
filename_match = re.fullmatch(r"^.*FAILED\(RESULT\) (.*)$", error_line)
|
||||
if filename_match:
|
||||
break
|
||||
error_line = parse_log_line(next(lines))
|
||||
# error line _should_ be next, but sometimes the output gets interleaved...
|
||||
# so we just skip until we find the error line
|
||||
error_line = next_line
|
||||
while True:
|
||||
# internal
|
||||
filename_match = re.fullmatch(r"^##\[error\].*FAILED\(RESULT\) (.*)$", error_line)
|
||||
if not filename_match:
|
||||
# codeql action
|
||||
filename_match = re.fullmatch(r"^.*FAILED\(RESULT\) (.*)$", error_line)
|
||||
if filename_match:
|
||||
break
|
||||
error_line = parse_log_line(next(lines))
|
||||
except StopIteration:
|
||||
LOGGER.warning("Encountered unexpected end of logs while parsing failure block.")
|
||||
break
|
||||
|
||||
full_path = filename_match.group(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user