# which should be excluded if the module is not present.
EXT_DEP_MODULES = {
'numpy' : re.compile('.*\.numpy_.*').match,
- 'pstats' : re.compile('.*\.pstats_.*').match
+ 'pstats' : re.compile('.*\.pstats_.*').match,
+ 'posix' : re.compile('.*\.posix_.*').match,
}
def get_numpy_include_dirs():
VER_DEP_MODULES = {
# tests are excluded if 'CurrentPythonVersion OP VersionTuple', i.e.
# (2,4) : (operator.le, ...) excludes ... when PyVer <= 2.4.x
+ (2,5) : (operator.lt, lambda x: x in ['run.any',
+ 'run.all',
+ ]),
(2,4) : (operator.le, lambda x: x in ['run.extern_builtins_T258'
]),
- (2,6) : (operator.lt, lambda x: x in ['run.print_function'
+ (2,6) : (operator.lt, lambda x: x in ['run.print_function',
+ 'run.cython3',
]),
(3,): (operator.ge, lambda x: x in ['run.non_future_division',
'compile.extsetslice',
def build_tests(self, test_class, path, workdir, module, expect_errors):
if expect_errors:
- languages = self.languages[:1]
+ if 'cpp' in module and 'cpp' in self.languages:
+ languages = ['cpp']
+ else:
+ languages = self.languages[:1]
else:
languages = self.languages
if 'cpp' in module and 'c' in languages:
use_listing_file = False,
cplus = self.language == 'cpp',
generate_pxi = False,
- evaluate_tree_assertions = True,
+# evaluate_tree_assertions = True,
+ evaluate_tree_assertions = False,
)
cython_compile(source, options=options,
full_module_name=module)
def __call__(self, testname):
return testname in self.excludes or testname.split('.')[-1] in self.excludes
+def refactor_for_py3(distdir, cy3_dir):
+ # need to convert Cython sources first
+ import lib2to3.refactor
+ from distutils.util import copydir_run_2to3
+ fixers = [ fix for fix in lib2to3.refactor.get_fixers_from_package("lib2to3.fixes")
+ if fix.split('fix_')[-1] not in ('next',)
+ ]
+ if not os.path.exists(cy3_dir):
+ os.makedirs(cy3_dir)
+ import distutils.log as dlog
+ dlog.set_threshold(dlog.DEBUG)
+ copydir_run_2to3(distdir, cy3_dir, fixer_names=fixers,
+ template = '''
+ global-exclude *
+ graft Cython
+ recursive-exclude Cython *
+ recursive-include Cython *.py *.pyx *.pxd
+ ''')
+ sys.path.insert(0, cy3_dir)
+
+
if __name__ == '__main__':
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-C", "--coverage", dest="coverage",
action="store_true", default=False,
help="collect source coverage data for the Compiler")
+ parser.add_option("--coverage-xml", dest="coverage_xml",
+ action="store_true", default=False,
+ help="collect source coverage data for the Compiler in XML format")
parser.add_option("-A", "--annotate", dest="annotate_source",
action="store_true", default=True,
help="generate annotated HTML versions of the test source files")
ROOTDIR = os.path.join(DISTDIR, 'tests')
WORKDIR = os.path.join(os.getcwd(), 'BUILD')
- if sys.version_info >= (3,1):
- options.doctests = False
- options.unittests = False
- options.pyregr = False
+ if sys.version_info[0] >= 3:
+ options.doctests = False
if options.with_cython:
- # need to convert Cython sources first
- import lib2to3.refactor
- from distutils.util import copydir_run_2to3
- fixers = [ fix for fix in lib2to3.refactor.get_fixers_from_package("lib2to3.fixes")
- if fix.split('fix_')[-1] not in ('next',)
- ]
- cy3_dir = os.path.join(WORKDIR, 'Cy3')
- if not os.path.exists(cy3_dir):
- os.makedirs(cy3_dir)
- import distutils.log as dlog
- dlog.set_threshold(dlog.DEBUG)
- copydir_run_2to3(DISTDIR, cy3_dir, fixer_names=fixers,
- template = '''
- global-exclude *
- graft Cython
- recursive-exclude Cython *
- recursive-include Cython *.py *.pyx *.pxd
- ''')
- sys.path.insert(0, cy3_dir)
- elif sys.version_info[0] >= 3:
- # make sure we do not import (or run) Cython itself (unless
- # 2to3 was already run)
- cy3_dir = os.path.join(WORKDIR, 'Cy3')
- if os.path.isdir(cy3_dir):
- sys.path.insert(0, cy3_dir)
- else:
- options.with_cython = False
- options.doctests = False
- options.unittests = False
- options.pyregr = False
-
- if options.coverage:
- import coverage
- coverage.erase()
- coverage.start()
+ try:
+ # try if Cython is installed in a Py3 version
+ import Cython.Compiler.Main
+ except Exception:
+ cy_modules = [ name for name in sys.modules
+ if name == 'Cython' or name.startswith('Cython.') ]
+ for name in cy_modules:
+ del sys.modules[name]
+ # hasn't been refactored yet - do it now
+ cy3_dir = os.path.join(WORKDIR, 'Cy3')
+ if sys.version_info >= (3,1):
+ refactor_for_py3(DISTDIR, cy3_dir)
+ elif os.path.isdir(cy3_dir):
+ sys.path.insert(0, cy3_dir)
+ else:
+ options.with_cython = False
WITH_CYTHON = options.with_cython
+ if options.coverage or options.coverage_xml:
+ if not WITH_CYTHON:
+ options.coverage = options.coverage_xml = False
+ else:
+ from coverage import coverage as _coverage
+ coverage = _coverage(branch=True)
+ coverage.erase()
+ coverage.start()
+
if WITH_CYTHON:
from Cython.Compiler.Main import \
CompilationOptions, \
sys.path.insert(0, os.path.split(libpath)[0])
CFLAGS.append("-DCYTHON_REFNANNY=1")
+ if options.xml_output_dir and options.fork:
+ # doesn't currently work together
+ sys.stderr.write("Disabling forked testing to support XML test output\n")
+ options.fork = False
+
test_bugs = False
if options.tickets:
for ticket_number in options.tickets:
result = test_runner.run(test_suite)
- if options.coverage:
+ if options.coverage or options.coverage_xml:
coverage.stop()
ignored_modules = ('Options', 'Version', 'DebugFlags', 'CmdLine')
modules = [ module for name, module in sys.modules.items()
if module is not None and
name.startswith('Cython.Compiler.') and
name[len('Cython.Compiler.'):] not in ignored_modules ]
- coverage.report(modules, show_missing=0)
+ if options.coverage:
+ coverage.report(modules, show_missing=0)
+ if options.coverage_xml:
+ coverage.xml_report(modules, outfile="coverage-report.xml")
if missing_dep_excluder.tests_missing_deps:
sys.stderr.write("Following tests excluded because of missing dependencies on your system:\n")