2011-03-16 20:52:14 -03:00
|
|
|
# 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
|
2015-05-06 00:33:17 -03:00
|
|
|
from test.support.script_helper import assert_python_failure
|
2011-03-16 20:52:14 -03:00
|
|
|
|
|
|
|
CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers")
|
2020-06-20 05:10:31 -03:00
|
|
|
CRASHER_FILES = os.path.join(glob.escape(CRASHER_DIR), "*.py")
|
2011-03-16 20:52:14 -03:00
|
|
|
|
|
|
|
infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"]
|
|
|
|
|
|
|
|
class CrasherTest(unittest.TestCase):
|
|
|
|
|
2011-03-19 15:54:01 -03:00
|
|
|
@unittest.skip("these tests are too fragile")
|
2011-03-16 20:52:14 -03:00
|
|
|
@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.
|
2011-03-17 12:04:34 -03:00
|
|
|
if test.support.verbose:
|
|
|
|
print("Checking crasher:", fname)
|
2011-03-16 20:52:14 -03:00
|
|
|
assert_python_failure(fname)
|
|
|
|
|
|
|
|
|
2015-04-13 17:00:43 -03:00
|
|
|
def tearDownModule():
|
2011-03-16 20:52:14 -03:00
|
|
|
test.support.reap_children()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2015-04-13 17:00:43 -03:00
|
|
|
unittest.main()
|