change working directory when running C compiler to make it work with relative path...
authorStefan Behnel <scoder@users.berlios.de>
Mon, 28 Apr 2008 08:56:49 +0000 (10:56 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 28 Apr 2008 08:56:49 +0000 (10:56 +0200)
runtests.py

index 85d9e99757807c97e9d7a36c1868f5e76c342aec..e0d062785af264d97cd2b42f0627534a8fa218aa 100644 (file)
@@ -121,21 +121,26 @@ class CythonCompileTestCase(unittest.TestCase):
                        full_module_name=module)
 
     def run_distutils(self, module, workdir, incdir):
-        build_extension = build_ext(distutils_distro)
-        build_extension.include_dirs = INCLUDE_DIRS[:]
-        if incdir:
-            build_extension.include_dirs.append(incdir)
-        build_extension.finalize_options()
-
-        extension = Extension(
-            module,
-            sources = [os.path.join(workdir, module + '.c')],
-            extra_compile_args = CFLAGS,
-            )
-        build_extension.extensions = [extension]
-        build_extension.build_temp = workdir
-        build_extension.build_lib  = workdir
-        build_extension.run()
+        cwd = os.getcwd()
+        os.chdir(workdir)
+        try:
+            build_extension = build_ext(distutils_distro)
+            build_extension.include_dirs = INCLUDE_DIRS[:]
+            if incdir:
+                build_extension.include_dirs.append(incdir)
+            build_extension.finalize_options()
+
+            extension = Extension(
+                module,
+                sources = [module + '.c'],
+                extra_compile_args = CFLAGS,
+                )
+            build_extension.extensions = [extension]
+            build_extension.build_temp = workdir
+            build_extension.build_lib  = workdir
+            build_extension.run()
+        finally:
+            os.chdir(cwd)
 
     def compile(self, directory, module, workdir, incdir, expect_errors):
         expected_errors = errors = ()
@@ -165,9 +170,6 @@ class CythonCompileTestCase(unittest.TestCase):
             self.run_distutils(module, workdir, incdir)
 
 class CythonRunTestCase(CythonCompileTestCase):
-    def shortDescription(self):
-        return "compiling and running " + self.module
-
     def runTest(self):
         self.run()