[pypy-commit] cffi default: Test and fix
arigo
noreply at buildbot.pypy.org
Sun Jul 15 21:38:30 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r655:0170315924eb
Date: 2012-07-15 21:38 +0200
http://bitbucket.org/cffi/cffi/changeset/0170315924eb/
Log: Test and fix
diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -61,6 +61,8 @@
return os.path.splitext(os.path.basename(self.modulefilename))[0]
def get_extension(self):
+ if self._status == 'init':
+ self._write_source()
sourcename = os.path.abspath(self.sourcefilename)
modname = self.get_module_name()
return ffiplatform.get_extension(sourcename, modname, **self.kwds)
diff --git a/testing/test_zdistutils.py b/testing/test_zdistutils.py
--- a/testing/test_zdistutils.py
+++ b/testing/test_zdistutils.py
@@ -1,4 +1,4 @@
-import os, imp, math, StringIO
+import os, imp, math, StringIO, random
import py
from cffi import FFI, FFIError
from cffi.verifier import Verifier
@@ -121,3 +121,12 @@
assert ext.sources == [os.path.abspath(v.sourcefilename)]
assert ext.name == v.get_module_name()
assert ext.define_macros == [('TEST_EXTENSION_OBJECT', '1')]
+
+def test_extension_forces_write_source():
+ ffi = FFI()
+ ffi.cdef("double sin(double x);")
+ csrc = '/*hi there!%r*/\n#include <math.h>\n' % random.random()
+ v = Verifier(ffi, csrc)
+ assert not os.path.exists(v.sourcefilename)
+ v.get_extension()
+ assert os.path.exists(v.sourcefilename)
More information about the pypy-commit
mailing list