Commit 6700fe73 authored by Michael Arntzenius's avatar Michael Arntzenius

tester.py: require "# should_error" in tests w/ non-0 exit code

parent d13518f2
...@@ -126,6 +126,7 @@ def run_test(fn, check_stats, run_memcheck): ...@@ -126,6 +126,7 @@ def run_test(fn, check_stats, run_memcheck):
jit_args = ["-crq"] + EXTRA_JIT_ARGS jit_args = ["-crq"] + EXTRA_JIT_ARGS
collect_stats = True collect_stats = True
expected = "success" expected = "success"
should_error = False
allow_warnings = [] allow_warnings = []
for l in open(fn): for l in open(fn):
l = l.strip() l = l.strip()
...@@ -141,6 +142,8 @@ def run_test(fn, check_stats, run_memcheck): ...@@ -141,6 +142,8 @@ def run_test(fn, check_stats, run_memcheck):
jit_args += l jit_args += l
elif l.startswith("# expected:"): elif l.startswith("# expected:"):
expected = l[len("# expected:"):].strip() expected = l[len("# expected:"):].strip()
elif l.startswith("# should_error"):
should_error = True
elif l.startswith("# fail-if:"): elif l.startswith("# fail-if:"):
condition = l.split(':', 1)[1].strip() condition = l.split(':', 1)[1].strip()
if eval(condition): if eval(condition):
...@@ -216,13 +219,27 @@ def run_test(fn, check_stats, run_memcheck): ...@@ -216,13 +219,27 @@ def run_test(fn, check_stats, run_memcheck):
if expected == "fail": if expected == "fail":
r += " Expected failure (got code %d, should be %d)" % (code, expected_code) r += " Expected failure (got code %d, should be %d)" % (code, expected_code)
return r return r
elif KEEP_GOING:
r += " \033[%dmFAILED\033[0m (%s)" % (color, msg)
failed.append(fn)
return r
else:
raise Exception("%s\n%s\n%s" % (msg, err, stderr))
elif should_error == (code == 0):
color = 31 # red
if code == 0:
msg = "Exited successfully; remove '# should_error' if this is expected"
else: else:
msg = "Exited with code %d; add '# should_error' if this is expected" % code
if KEEP_GOING: if KEEP_GOING:
r += " \033[%dmFAILED\033[0m (%s)" % (color, msg) r += " \033[%dmFAILED\033[0m (%s)" % (color, msg)
failed.append(fn) failed.append(fn)
return r return r
else: else:
raise Exception("%s\n%s\n%s" % (msg, err, stderr)) raise Exception(msg)
elif out != expected_out: elif out != expected_out:
if expected == "fail": if expected == "fail":
r += " Expected failure (bad output)" r += " Expected failure (bad output)"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment