[pypy-commit] pypy refine-testrunner: testrunner: simplify and fix interpret_exitcode tests
RonnyPfannschmidt
noreply at buildbot.pypy.org
Thu Jan 23 23:08:42 CET 2014
Author: Ronny Pfannschmidt <opensource at ronnypfannschmidt.de>
Branch: refine-testrunner
Changeset: r68892:a58339b0503c
Date: 2014-01-23 23:02 +0100
http://bitbucket.org/pypy/pypy/changeset/a58339b0503c/
Log: testrunner: simplify and fix interpret_exitcode tests
diff --git a/testrunner/test/test_util.py b/testrunner/test/test_util.py
--- a/testrunner/test/test_util.py
+++ b/testrunner/test/test_util.py
@@ -105,32 +105,28 @@
out = out.read()
assert out == "42\n"
+def make_test(id, input, expected):
+ def test_interpret_exitcode():
+ print(input)
+ print(expected)
+ failure, extralog = util.interpret_exitcode(
+ input[0], 'test_foo', input[1])
+ assert (failure, extralog) == expected
+ test_interpret_exitcode.__name__ += str(id)
+ globals()[test_interpret_exitcode.__name__] = test_interpret_exitcode
-def test_interpret_exitcode():
- failure, extralog = util.interpret_exitcode(0, "test_foo", '')
- assert not failure
- assert extralog == ""
+cases = [
+ # input expected output
+ # exit, logdata, failure, extralog
+ (0, '', False, ''),
+ (1, '', True, "! test_foo\n Exit code 1.\n"),
+ (1, 'F foo\n', True, ' (somefailed=True in test_foo)\n'),
+ (2, '', True, "! test_foo\n Exit code 2.\n"),
+ (-signal.SIGSEGV, '', True, "! test_foo\n Killed by SIGSEGV.\n"),
- failure, extralog = util.interpret_exitcode(1, "test_foo", "")
- assert failure
- assert extralog == """! test_foo
- Exit code 1.
-"""
- assert extralog == " (somefailed=True in test_foo)\n" #xXX find location
+]
- failure, extralog = util.interpret_exitcode(1, "test_foo", "F Foo\n")
- assert failure
- assert extralog == ""
+for n, i in enumerate(cases):
+ make_test(n, i[:2], i[2:])
- failure, extralog = util.interpret_exitcode(2, "test_foo")
- assert failure
- assert extralog == """! test_foo
- Exit code 2.
-"""
- failure, extralog = util.interpret_exitcode(-signal.SIGSEGV,
- "test_foo")
- assert failure
- assert extralog == """! test_foo
- Killed by SIGSEGV.
-"""
More information about the pypy-commit
mailing list