diff --git a/misc/scripts/accept-expected-changes-from-ci.py b/misc/scripts/accept-expected-changes-from-ci.py index a11bfe9547f9..e5f583044d40 100755 --- a/misc/scripts/accept-expected-changes-from-ci.py +++ b/misc/scripts/accept-expected-changes-from-ci.py @@ -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)