Commit 18c69b1c authored by Robert Bradshaw's avatar Robert Bradshaw

Merge branch 'release'

parents 56d9591a 8ff1807d
...@@ -29,6 +29,49 @@ with open(codefile) as f: ...@@ -29,6 +29,49 @@ with open(codefile) as f:
# can't access the module anymore. Get it from sys.modules instead. # can't access the module anymore. Get it from sys.modules instead.
build_ext = sys.modules['Cython.Distutils.build_ext'] build_ext = sys.modules['Cython.Distutils.build_ext']
have_gdb = None
def test_gdb():
global have_gdb
if have_gdb is None:
try:
p = subprocess.Popen(['gdb', '-v'], stdout=subprocess.PIPE)
have_gdb = True
except OSError:
# gdb was not installed
have_gdb = False
else:
gdb_version = p.stdout.read().decode('ascii')
p.wait()
p.stdout.close()
if have_gdb:
# Based on Lib/test/test_gdb.py
regex = "^GNU gdb [^\d]*(\d+)\.(\d+)"
gdb_version_number = list(map(int, re.search(regex, gdb_version).groups()))
if gdb_version_number >= [7, 2]:
python_version_script = tempfile.NamedTemporaryFile(mode='w+')
python_version_script.write(
'python import sys; print("%s %s" % sys.version_info[:2])')
python_version_script.flush()
p = subprocess.Popen(['gdb', '-batch', '-x', python_version_script.name],
stdout=subprocess.PIPE)
python_version = p.stdout.read().decode('ascii')
p.wait()
python_version_number = list(map(int, python_version.split()))
# Be Python 3 compatible
if (not have_gdb
or gdb_version_number < [7, 2]
or python_version_number < [2, 6]):
warnings.warn(
'Skipping gdb tests, need gdb >= 7.2 with Python >= 2.6')
have_gdb = False
return have_gdb
class DebuggerTestCase(unittest.TestCase): class DebuggerTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -36,6 +79,9 @@ class DebuggerTestCase(unittest.TestCase): ...@@ -36,6 +79,9 @@ class DebuggerTestCase(unittest.TestCase):
Run gdb and have cygdb import the debug information from the code Run gdb and have cygdb import the debug information from the code
defined in TestParseTreeTransforms's setUp method defined in TestParseTreeTransforms's setUp method
""" """
if not test_gdb():
return
self.tempdir = tempfile.mkdtemp() self.tempdir = tempfile.mkdtemp()
self.destfile = os.path.join(self.tempdir, 'codefile.pyx') self.destfile = os.path.join(self.tempdir, 'codefile.pyx')
self.debug_dest = os.path.join(self.tempdir, self.debug_dest = os.path.join(self.tempdir,
...@@ -44,62 +90,69 @@ class DebuggerTestCase(unittest.TestCase): ...@@ -44,62 +90,69 @@ class DebuggerTestCase(unittest.TestCase):
self.cfuncs_destfile = os.path.join(self.tempdir, 'cfuncs') self.cfuncs_destfile = os.path.join(self.tempdir, 'cfuncs')
self.cwd = os.getcwd() self.cwd = os.getcwd()
os.chdir(self.tempdir) try:
os.chdir(self.tempdir)
shutil.copy(codefile, self.destfile)
shutil.copy(cfuncs_file, self.cfuncs_destfile + '.c') shutil.copy(codefile, self.destfile)
shutil.copy(cfuncs_file, self.cfuncs_destfile + '.c')
compiler = ccompiler.new_compiler()
compiler.compile(['cfuncs.c'], debug=True, extra_postargs=['-fPIC']) compiler = ccompiler.new_compiler()
compiler.compile(['cfuncs.c'], debug=True, extra_postargs=['-fPIC'])
opts = dict(
test_directory=self.tempdir, opts = dict(
module='codefile', test_directory=self.tempdir,
) module='codefile',
)
optimization_disabler = build_ext.Optimization()
optimization_disabler.disable_optimization() optimization_disabler = build_ext.Optimization()
optimization_disabler.disable_optimization()
cython_compile_testcase = runtests.CythonCompileTestCase(
workdir=self.tempdir, cython_compile_testcase = runtests.CythonCompileTestCase(
# we clean up everything (not only compiled files) workdir=self.tempdir,
cleanup_workdir=False, # we clean up everything (not only compiled files)
**opts cleanup_workdir=False,
) **opts
)
cython_compile_testcase.run_cython(
targetdir=self.tempdir, cython_compile_testcase.run_cython(
incdir=None, targetdir=self.tempdir,
annotate=False, incdir=None,
extra_compile_options={ annotate=False,
'gdb_debug':True, extra_compile_options={
'output_dir':self.tempdir, 'gdb_debug':True,
}, 'output_dir':self.tempdir,
**opts },
) **opts
)
cython_compile_testcase.run_distutils(
incdir=None, cython_compile_testcase.run_distutils(
workdir=self.tempdir, incdir=None,
extra_extension_args={'extra_objects':['cfuncs.o']}, workdir=self.tempdir,
**opts extra_extension_args={'extra_objects':['cfuncs.o']},
) **opts
)
optimization_disabler.restore_state()
optimization_disabler.restore_state()
# ext = Cython.Distutils.extension.Extension(
# 'codefile', # ext = Cython.Distutils.extension.Extension(
# ['codefile.pyx'], # 'codefile',
# pyrex_gdb=True, # ['codefile.pyx'],
# extra_objects=['cfuncs.o']) # pyrex_gdb=True,
# # extra_objects=['cfuncs.o'])
# distutils.core.setup( #
# script_args=['build_ext', '--inplace'], # distutils.core.setup(
# ext_modules=[ext], # script_args=['build_ext', '--inplace'],
# cmdclass=dict(build_ext=Cython.Distutils.build_ext) # ext_modules=[ext],
# ) # cmdclass=dict(build_ext=Cython.Distutils.build_ext)
# )
except:
os.chdir(self.cwd)
raise
def tearDown(self): def tearDown(self):
if not test_gdb():
return
os.chdir(self.cwd) os.chdir(self.cwd)
shutil.rmtree(self.tempdir) shutil.rmtree(self.tempdir)
...@@ -107,6 +160,9 @@ class DebuggerTestCase(unittest.TestCase): ...@@ -107,6 +160,9 @@ class DebuggerTestCase(unittest.TestCase):
class GdbDebuggerTestCase(DebuggerTestCase): class GdbDebuggerTestCase(DebuggerTestCase):
def setUp(self): def setUp(self):
if not test_gdb():
return
super(GdbDebuggerTestCase, self).setUp() super(GdbDebuggerTestCase, self).setUp()
prefix_code = textwrap.dedent('''\ prefix_code = textwrap.dedent('''\
...@@ -166,25 +222,26 @@ class GdbDebuggerTestCase(DebuggerTestCase): ...@@ -166,25 +222,26 @@ class GdbDebuggerTestCase(DebuggerTestCase):
p.wait() p.wait()
p.stdout.close() p.stdout.close()
if have_gdb:
python_version_script = tempfile.NamedTemporaryFile(mode='w+')
python_version_script.write(
'python import sys; print("%s %s" % sys.version_info[:2])')
python_version_script.flush()
p = subprocess.Popen(['gdb', '-batch', '-x', python_version_script.name],
stdout=subprocess.PIPE)
python_version = p.stdout.read().decode('ascii')
p.wait()
python_version_number = [int(a) for a in python_version.split()]
if have_gdb: if have_gdb:
# Based on Lib/test/test_gdb.py # Based on Lib/test/test_gdb.py
regex = "^GNU gdb [^\d]*(\d+)\.(\d+)" regex = "^GNU gdb [^\d]*(\d+)\.(\d+)"
gdb_version_number = re.search(regex, gdb_version).groups() gdb_version_number = list(map(int, re.search(regex, gdb_version).groups()))
if gdb_version_number >= [7, 2]:
python_version_script = tempfile.NamedTemporaryFile(mode='w+')
python_version_script.write(
'python import sys; print("%s %s" % sys.version_info[:2])')
python_version_script.flush()
p = subprocess.Popen(['gdb', '-batch', '-x', python_version_script.name],
stdout=subprocess.PIPE)
python_version = p.stdout.read().decode('ascii')
p.wait()
python_version_number = list(map(int, python_version.split()))
# Be Python 3 compatible # Be Python 3 compatible
if (not have_gdb if (not have_gdb
or list(map(int, gdb_version_number)) < [7, 2] or gdb_version_number < [7, 2]
or python_version_number < [2, 6]): or python_version_number < [2, 6]):
self.p = None self.p = None
warnings.warn( warnings.warn(
...@@ -197,6 +254,9 @@ class GdbDebuggerTestCase(DebuggerTestCase): ...@@ -197,6 +254,9 @@ class GdbDebuggerTestCase(DebuggerTestCase):
env=env) env=env)
def tearDown(self): def tearDown(self):
if not test_gdb():
return
super(GdbDebuggerTestCase, self).tearDown() super(GdbDebuggerTestCase, self).tearDown()
if self.p: if self.p:
self.p.stderr.close() self.p.stderr.close()
...@@ -207,7 +267,7 @@ class GdbDebuggerTestCase(DebuggerTestCase): ...@@ -207,7 +267,7 @@ class GdbDebuggerTestCase(DebuggerTestCase):
class TestAll(GdbDebuggerTestCase): class TestAll(GdbDebuggerTestCase):
def test_all(self): def test_all(self):
if self.p is None: if not test_gdb():
return return
out, err = self.p.communicate() out, err = self.p.communicate()
......
__version__ = "0.14.1rc2" __version__ = "0.14.1rc3"
# Void cython.* directives (for case insensitive operating systems). # Void cython.* directives (for case insensitive operating systems).
from Cython.Shadow import * from Cython.Shadow import *
...@@ -26,6 +26,18 @@ try: ...@@ -26,6 +26,18 @@ try:
except ImportError: # No threads, no problems except ImportError: # No threads, no problems
threading = None threading = None
if sys.platform == 'win32':
# TODO: Figure out why this hackery (see http://thread.gmane.org/gmane.comp.python.cython.devel/8280/).
config_files = distutils_distro.find_config_files()
try: config_files.remove('setup.cfg')
except ValueError: pass
distutils_distro.parse_config_files(config_files)
cfgfiles = distutils_distro.find_config_files()
try: cfgfiles.remove('setup.cfg')
except ValueError: pass
distutils_distro.parse_config_files(cfgfiles)
WITH_CYTHON = True WITH_CYTHON = True
...@@ -981,6 +993,9 @@ def check_thread_termination(ignore_seen=True): ...@@ -981,6 +993,9 @@ def check_thread_termination(ignore_seen=True):
raise PendingThreadsError("left-over threads found after running test") raise PendingThreadsError("left-over threads found after running test")
def main(): def main():
DISTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]))
from optparse import OptionParser from optparse import OptionParser
parser = OptionParser() parser = OptionParser()
parser.add_option("--no-cleanup", dest="cleanup_workdir", parser.add_option("--no-cleanup", dest="cleanup_workdir",
...@@ -1051,12 +1066,15 @@ def main(): ...@@ -1051,12 +1066,15 @@ def main():
parser.add_option("--exit-ok", dest="exit_ok", default=False, parser.add_option("--exit-ok", dest="exit_ok", default=False,
action="store_true", action="store_true",
help="exit without error code even on test failures") help="exit without error code even on test failures")
parser.add_option("--root-dir", dest="root_dir", default=os.path.join(DISTDIR, 'tests'),
help="working directory")
parser.add_option("--work-dir", dest="work_dir", default=os.path.join(os.getcwd(), 'BUILD'),
help="working directory")
options, cmd_args = parser.parse_args() options, cmd_args = parser.parse_args()
DISTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])) ROOTDIR = os.path.abspath(options.root_dir)
ROOTDIR = os.path.join(DISTDIR, 'tests') WORKDIR = os.path.abspath(options.work_dir)
WORKDIR = os.path.join(os.getcwd(), 'BUILD')
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
options.doctests = False options.doctests = False
...@@ -1167,7 +1185,7 @@ def main(): ...@@ -1167,7 +1185,7 @@ def main():
exclude_selectors += [ re.compile(r, re.I|re.U).search for r in options.exclude ] exclude_selectors += [ re.compile(r, re.I|re.U).search for r in options.exclude ]
if not test_bugs: if not test_bugs:
exclude_selectors += [ FileListExcluder("tests/bugs.txt") ] exclude_selectors += [ FileListExcluder(os.path.join(ROOTDIR, "bugs.txt")) ]
if sys.platform in ['win32', 'cygwin'] and sys.version_info < (2,6): if sys.platform in ['win32', 'cygwin'] and sys.version_info < (2,6):
exclude_selectors += [ lambda x: x == "run.specialfloat" ] exclude_selectors += [ lambda x: x == "run.specialfloat" ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment