[Python-checkins] cpython: Exercise crashers to ensure they are still covering known error cases

nick.coghlan python-checkins at python.org
Thu Mar 17 01:01:30 CET 2011


http://hg.python.org/cpython/rev/e3fb176add41
changeset:   68628:e3fb176add41
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Wed Mar 16 19:52:14 2011 -0400
summary:
  Exercise crashers to ensure they are still covering known error cases

files:
  Lib/test/crashers/README
  Lib/test/test_crashers.py

diff --git a/Lib/test/crashers/README b/Lib/test/crashers/README
--- a/Lib/test/crashers/README
+++ b/Lib/test/crashers/README
@@ -14,3 +14,7 @@
 Once the crash is fixed, the test case should be moved into an appropriate test
 (even if it was originally from the test suite).  This ensures the regression
 doesn't happen again.  And if it does, it should be easier to track down.
+
+Also see Lib/test_crashers.py which exercises the crashers in this directory.
+In particular, make sure to add any new infinite loop crashers to the black
+list so it doesn't try to run them.
diff --git a/Lib/test/test_crashers.py b/Lib/test/test_crashers.py
new file mode 100644
--- /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()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list