Skip to content

Commit 06fe20e

Browse files
authored
Merge pull request #1396 from ldrumm/INPUT_END
[test] Fix infinite loop when we run out of input
2 parents 8499b57 + 1b6c9c2 commit 06fe20e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cmake/match.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ def main():
9393
print_incorrect_match(match_idx + 1, input_lines[input_idx].strip(), "");
9494
print_content(input_lines, match_lines, ignored_lines)
9595
sys.exit(1)
96+
elif status == Status.INPUT_END:
97+
# If we get to the end of the input, but still have pending matches,
98+
# then that's a failure unless all pending matches are optional -
99+
# otherwise we're done
100+
while match_idx < len(match_lines):
101+
if not (match_lines[match_idx].startswith(Tag.OPT.value) or
102+
match_lines[match_idx].startswith(Tag.IGNORE.value)):
103+
print_incorrect_match(match_idx + 1, "", match_lines[match_idx]);
104+
print_content(input_lines, match_lines, ignored_lines)
105+
sys.exit(1)
106+
match_idx += 1
107+
sys.exit(0)
96108

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

0 commit comments

Comments
 (0)