#!/usr/bin/python
-import os, sys, re, shutil, unittest, doctest, ctypes
+import os, sys, re, shutil, unittest, doctest
WITH_CYTHON = True
distutils_distro = Distribution()
TEST_DIRS = ['compile', 'errors', 'run', 'pyregr']
-TEST_RUN_DIRS = ['run', 'pyregr']
+TEST_RUN_DIRS = ['run', 'pyregr', 'bugs']
# Lists external modules, and a matcher matching tests
# which should be excluded if the module is not present.
self.setUp()
self.runCompileTest()
if not self.cython_only:
- sys.stderr.write('running doctests in %s ...\n' % self.module)
doctest.DocTestSuite(self.module).run(result)
except Exception:
result.addError(self, sys.exc_info())
try:
self.setUp()
self.runCompileTest()
- sys.stderr.write('running tests in %s ...\n' % self.module)
unittest.defaultTestLoader.loadTestsFromName(self.module).run(result)
except Exception:
result.addError(self, sys.exc_info())
parser.add_option("--cython-only", dest="cython_only",
action="store_true", default=False,
help="only compile pyx to c, do not run C compiler or run the tests")
- parser.add_option("--refnanny", dest="with_refnanny",
- action="store_true", default=False,
- help="also test that Cython-generated code does correct reference counting")
+ parser.add_option("--no-refnanny", dest="with_refnanny",
+ action="store_false", default=True,
+ help="do not regression test reference counting")
parser.add_option("--sys-pyregr", dest="system_pyregr",
action="store_true", default=False,
help="run the regression tests of the CPython installation")
from Cython.Compiler import Errors
Errors.LEVEL = 0 # show all warnings
- if options.with_refnanny:
- ctypes.PyDLL("Cython/Runtime/refnanny.so", mode=ctypes.RTLD_GLOBAL)
- sys.path.append("Cython/Runtime")
- import refnanny
- del sys.path[-1]
- CFLAGS.append("-DCYTHON_REFNANNY")
-
# RUN ALL TESTS!
ROOTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'tests')
WORKDIR = os.path.join(os.getcwd(), 'BUILD')
UNITTEST_ROOT = os.path.join(os.getcwd(), UNITTEST_MODULE)
if WITH_CYTHON:
if os.path.exists(WORKDIR):
- shutil.rmtree(WORKDIR, ignore_errors=True)
+ for path in os.listdir(WORKDIR):
+ if path in ("support",): continue
+ shutil.rmtree(os.path.join(WORKDIR, path), ignore_errors=True)
if not os.path.exists(WORKDIR):
os.makedirs(WORKDIR)
sys.stderr.write("Python %s\n" % sys.version)
sys.stderr.write("\n")
+ if options.with_refnanny:
+ from pyximport.pyxbuild import pyx_to_dll
+ libpath = pyx_to_dll(os.path.join("Cython", "Runtime", "refnanny.pyx"),
+ build_in_temp=True,
+ pyxbuild_dir=os.path.join(WORKDIR, "support"))
+ sys.path.insert(0, os.path.split(libpath)[0])
+ CFLAGS.append("-DCYTHON_REFNANNY")
+
test_bugs = False
- for ticket_number in options.tickets:
- test_bugs = True
- cmd_args.append('bugs.*T%s$' % ticket_number)
+ if options.tickets:
+ for ticket_number in options.tickets:
+ test_bugs = True
+ cmd_args.append('bugs.*T%s$' % ticket_number)
if not test_bugs:
for selector in cmd_args:
if selector.startswith('bugs'):
sys.stderr.write(" %s\n" % test)
if options.with_refnanny:
+ import refnanny
sys.stderr.write("\n".join([repr(x) for x in refnanny.reflog]))