Skip to content

Commit 1b6c9c2

Browse files
committed
[test] Fix infinite loop when we run out of input
d6930c7 introduced Status.INPUT_END but didn't introduce the means to handle that eventuality. It looks like the intention might have been to exit with success if we've got to the end of input. However, if we run out of input and still have matches pending, I'm treating this as a failure
1 parent e0393a4 commit 1b6c9c2

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)