summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_crashers.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2011-03-16 23:52:14 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2011-03-16 23:52:14 (GMT)
commitc95ec3d560dd21e678958016aa46313f619b83e7 (patch)
treeea840e87f5324667b97552f3bc62b2c78b466de0 /Lib/test/test_crashers.py
parentcfec350e63ee601ce5f777d0780355b06410ccf9 (diff)
downloadcpython-c95ec3d560dd21e678958016aa46313f619b83e7.zip
cpython-c95ec3d560dd21e678958016aa46313f619b83e7.tar.gz
cpython-c95ec3d560dd21e678958016aa46313f619b83e7.tar.bz2
Exercise crashers to ensure they are still covering known error cases
Diffstat (limited to 'Lib/test/test_crashers.py')
-rw-r--r--Lib/test/test_crashers.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_crashers.py b/Lib/test/test_crashers.py
new file mode 100644
index 0000000..ee612c2
--- /dev/null
+++ b/Lib/test/test_crashers.py
@@ -0,0 +1,35 @@
+# Tests that the crashers in the Lib/test/crashers directory actually
+# do crash the interpreter as expected
+#
+# If a crasher is fixed, it should be moved elsewhere in the test suite to
+# ensure it continues to work correctly.
+
+import unittest
+import glob
+import os.path
+import test.support
+from test.script_helper import assert_python_failure
+
+CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers")
+CRASHER_FILES = os.path.join(CRASHER_DIR, "*.py")
+
+infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"]
+
+class CrasherTest(unittest.TestCase):
+
+ @test.support.cpython_only
+ def test_crashers_crash(self):
+ for fname in glob.glob(CRASHER_FILES):
+ if os.path.basename(fname) in infinite_loops:
+ continue
+ # Some "crashers" only trigger an exception rather than a
+ # segfault. Consider that an acceptable outcome.
+ assert_python_failure(fname)
+
+
+def test_main():
+ test.support.run_unittest(CrasherTest)
+ test.support.reap_children()
+
+if __name__ == "__main__":
+ test_main()