Skip to content

Commit

Permalink
Runtime Tests: Make EXPECT_NONE operate on plain text (not regex) pat…
Browse files Browse the repository at this point in the history
…terns

EXPECT_REGEX_NONE is introduced to preserve the old behaviour.
  • Loading branch information
ajor committed Mar 12, 2024
1 parent a80798e commit b1dd370
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/runtime/engine/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ def __read_test_struct(test, test_suite):
prog = line
elif item_name == 'EXPECT':
expects.append(Expect(line, 'text'))
elif item_name == 'EXPECT_NONE':
expects.append(Expect(line, 'text_none'))
elif item_name == 'EXPECT_REGEX':
expects.append(Expect(line, 'regex'))
elif item_name == 'EXPECT_NONE':
elif item_name == 'EXPECT_REGEX_NONE':
expects.append(Expect(line, 'regex_none'))
elif item_name == 'EXPECT_FILE':
has_exact_expect = True
Expand Down
5 changes: 5 additions & 0 deletions tests/runtime/engine/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ def check_expect(expect, output):
if expect.mode == "text":
# Raw text match on an entire line, ignoring leading/trailing whitespace
return re.search(f"^\s*{re.escape(expect.expect)}\s*$", output, re.M)
elif expect.mode == "text_none":
return not re.search(f"^\s*{re.escape(expect.expect)}\s*$", output, re.M)
elif expect.mode == "regex":
return re.search(expect.expect, output, re.M)
elif expect.mode == "regex_none":
Expand Down Expand Up @@ -458,6 +460,9 @@ def print_befores_and_after_output():
if failed_expect.mode == "text":
print('\tExpected: ' + failed_expect.expect)
print('\tFound:\n' + to_utf8(output))
elif failed_expect.mode == "text_none":
print('\tExpected no: ' + failed_expect.expect)
print('\tFound:\n' + to_utf8(output))
elif failed_expect.mode == "regex":
print('\tExpected REGEX: ' + failed_expect.expect)
print('\tFound:\n' + to_utf8(output))
Expand Down

0 comments on commit b1dd370

Please sign in to comment.