Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r77659:a3eaece77234
Date: 2015-05-28 18:18 +0200
http://bitbucket.org/pypy/pypy/changeset/a3eaece77234/

Log:    update to cffi/4f05d11fa6ab

diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -7,7 +7,8 @@
 
 
 @unwrap_spec(cdef=str, module_name=str, source=str)
-def prepare(space, cdef, module_name, source, w_includes=None):
+def prepare(space, cdef, module_name, source, w_includes=None,
+            w_extra_source=None):
     try:
         import cffi
         from cffi import FFI            # <== the system one, which
@@ -45,9 +46,13 @@
     ffi.emit_c_code(c_file)
 
     base_module_name = module_name.split('.')[-1]
+    sources = []
+    if w_extra_source is not None:
+        sources.append(space.str_w(w_extra_source))
     ext = ffiplatform.get_extension(c_file, module_name,
             include_dirs=[str(rdir)],
-            export_symbols=['_cffi_pypyinit_' + base_module_name])
+            export_symbols=['_cffi_pypyinit_' + base_module_name],
+            sources=sources)
     ffiplatform.compile(str(rdir), ext)
 
     for extension in ['so', 'pyd', 'dylib']:
@@ -79,6 +84,8 @@
         if cls.runappdirect:
             py.test.skip("not a test for -A")
         cls.w_prepare = cls.space.wrap(interp2app(prepare))
+        cls.w_udir = cls.space.wrap(str(udir))
+        cls.w_os_sep = cls.space.wrap(os.sep)
 
     def setup_method(self, meth):
         self._w_modules = self.space.appexec([], """():
@@ -849,3 +856,15 @@
         p = ffi.addressof(lib, 'globvar')
         assert ffi.typeof(p) == ffi.typeof('opaque_t *')
         assert ffi.string(ffi.cast("char *", p), 8) == "hello"
+
+    def test_constant_of_value_unknown_to_the_compiler(self):
+        extra_c_source = self.udir + self.os_sep + (
+            'extra_test_constant_of_value_unknown_to_the_compiler.c')
+        with open(extra_c_source, 'w') as f:
+            f.write('const int external_foo = 42;\n')
+        ffi, lib = self.prepare(
+            "const int external_foo;",
+            'test_constant_of_value_unknown_to_the_compiler',
+            "extern const int external_foo;",
+            extra_source=extra_c_source)
+        assert lib.external_foo == 42
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to