Skip to content

Commit

Permalink
Merge pull request #1396 from ldrumm/INPUT_END
Browse files Browse the repository at this point in the history
[test] Fix infinite loop when we run out of input
  • Loading branch information
pbalcer authored Mar 5, 2024
2 parents 8499b57 + 1b6c9c2 commit 06fe20e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmake/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def main():
print_incorrect_match(match_idx + 1, input_lines[input_idx].strip(), "");
print_content(input_lines, match_lines, ignored_lines)
sys.exit(1)
elif status == Status.INPUT_END:
# If we get to the end of the input, but still have pending matches,
# then that's a failure unless all pending matches are optional -
# otherwise we're done
while match_idx < len(match_lines):
if not (match_lines[match_idx].startswith(Tag.OPT.value) or
match_lines[match_idx].startswith(Tag.IGNORE.value)):
print_incorrect_match(match_idx + 1, "", match_lines[match_idx]);
print_content(input_lines, match_lines, ignored_lines)
sys.exit(1)
match_idx += 1
sys.exit(0)

input_line = input_lines[input_idx].strip() if input_idx < len(input_lines) else ""
match_line = match_lines[match_idx]
Expand Down

0 comments on commit 06fe20e

Please sign in to comment.