Nick Coghlan | c95ec3d | 2011-03-16 19:52:14 -0400 | [diff] [blame] | 1 | # Tests that the crashers in the Lib/test/crashers directory actually |
| 2 | # do crash the interpreter as expected |
| 3 | # |
| 4 | # If a crasher is fixed, it should be moved elsewhere in the test suite to |
| 5 | # ensure it continues to work correctly. |
| 6 | |
| 7 | import unittest |
| 8 | import glob |
| 9 | import os.path |
| 10 | import test.support |
| 11 | from test.script_helper import assert_python_failure |
| 12 | |
| 13 | CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers") |
| 14 | CRASHER_FILES = os.path.join(CRASHER_DIR, "*.py") |
| 15 | |
| 16 | infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"] |
| 17 | |
| 18 | class CrasherTest(unittest.TestCase): |
| 19 | |
| 20 | @test.support.cpython_only |
| 21 | def test_crashers_crash(self): |
| 22 | for fname in glob.glob(CRASHER_FILES): |
| 23 | if os.path.basename(fname) in infinite_loops: |
| 24 | continue |
| 25 | # Some "crashers" only trigger an exception rather than a |
| 26 | # segfault. Consider that an acceptable outcome. |
| 27 | assert_python_failure(fname) |
| 28 | |
| 29 | |
| 30 | def test_main(): |
| 31 | test.support.run_unittest(CrasherTest) |
| 32 | test.support.reap_children() |
| 33 | |
| 34 | if __name__ == "__main__": |
| 35 | test_main() |