Commit bd34c9af authored by Robert Bradshaw's avatar Robert Bradshaw

Restore cwd if debugger setUp() fails (to avoid breaking later tests).

parent d6e9ff9c
...@@ -90,60 +90,65 @@ class DebuggerTestCase(unittest.TestCase): ...@@ -90,60 +90,65 @@ 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(): if not test_gdb():
......
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