summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2019-11-07 12:24:21 +0100
committerArmin Rigo <arigo@tunes.org>2019-11-07 12:24:21 +0100
commit95724a60eb1ed1f8b508471405801697d0b28758 (patch)
treef8c7a1a9c87da61942b26a8377d9c42c3d3f623d /testing
parent33d747324c70eb197be7da7130df5a3bee85a566 (diff)
downloadcffi-95724a60eb1ed1f8b508471405801697d0b28758.tar.gz
Tweak the '-Wno-*' arguments passed to gcc during tests
Diffstat (limited to 'testing')
-rw-r--r--testing/cffi0/test_verify.py12
-rw-r--r--testing/cffi1/test_recompiler.py5
-rw-r--r--testing/cffi1/test_verify1.py14
-rw-r--r--testing/support.py23
4 files changed, 27 insertions, 27 deletions
diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py
index f4ea092..52ce214 100644
--- a/testing/cffi0/test_verify.py
+++ b/testing/cffi0/test_verify.py
@@ -3,6 +3,7 @@ import pytest
import sys, os, math, weakref
from cffi import FFI, VerificationError, VerificationMissing, model, FFIError
from testing.support import *
+from testing.support import extra_compile_args
lib_m = ['m']
@@ -13,17 +14,6 @@ if sys.platform == 'win32':
lib_m = ['msvcrt']
pass # no obvious -Werror equivalent on MSVC
else:
- if (sys.platform == 'darwin' and
- [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
- # assume a standard clang or gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
- # special things for clang
- extra_compile_args.append('-Qunused-arguments')
- else:
- # assume a standard gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
- '-Wno-unused-parameter']
-
class FFI(FFI):
def verify(self, *args, **kwds):
return super(FFI, self).verify(
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
index cf4e9cd..f4ce11b 100644
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -34,8 +34,9 @@ def verify(ffi, module_name, source, *args, **kwds):
source = 'extern "C" {\n%s\n}' % (source,)
elif sys.platform != 'win32':
# add '-Werror' to the existing 'extra_compile_args' flags
+ from testing.support import extra_compile_args
kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
- ['-Werror'])
+ extra_compile_args)
return _verify(ffi, module_name, source, *args, **kwds)
def test_set_source_no_slashes():
@@ -2038,7 +2039,7 @@ def test_function_returns_float_complex():
ffi.cdef("float _Complex f1(float a, float b);");
lib = verify(ffi, "test_function_returns_float_complex", """
#include <complex.h>
- static float _Complex f1(float a, float b) { return a + I*2.0*b; }
+ static float _Complex f1(float a, float b) { return a + I*2.0f*b; }
""", no_cpp=True) # <complex.h> fails on some systems with C++
result = lib.f1(1.25, 5.1)
assert type(result) == complex
diff --git a/testing/cffi1/test_verify1.py b/testing/cffi1/test_verify1.py
index 826b978..33244cc 100644
--- a/testing/cffi1/test_verify1.py
+++ b/testing/cffi1/test_verify1.py
@@ -4,7 +4,7 @@ from cffi import FFI, FFIError, VerificationError, VerificationMissing, model
from cffi import CDefError
from cffi import recompiler
from testing.support import *
-from testing.support import _verify
+from testing.support import _verify, extra_compile_args
import _cffi_backend
lib_m = ['m']
@@ -13,18 +13,6 @@ if sys.platform == 'win32':
import distutils.ccompiler
if distutils.ccompiler.get_default_compiler() == 'msvc':
lib_m = ['msvcrt']
- extra_compile_args = [] # no obvious -Werror equivalent on MSVC
-else:
- if (sys.platform == 'darwin' and
- [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
- # assume a standard clang or gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
- # special things for clang
- extra_compile_args.append('-Qunused-arguments')
- else:
- # assume a standard gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
- '-Wno-unused-parameter']
class FFI(FFI):
error = _cffi_backend.FFI.error
diff --git a/testing/support.py b/testing/support.py
index 65f010c..d64ae3d 100644
--- a/testing/support.py
+++ b/testing/support.py
@@ -1,4 +1,4 @@
-import sys
+import sys, os
if sys.version_info < (3,):
__all__ = ['u']
@@ -86,3 +86,24 @@ def _verify(ffi, module_name, preamble, *args, **kwds):
if not name.startswith('_') and not hasattr(module.ffi, name):
setattr(ffi, name, NotImplemented)
return module.lib
+
+
+# For testing, we call gcc with "-Werror". This is fragile because newer
+# versions of gcc are always better at producing warnings, particularly for
+# auto-generated code. We need here to adapt and silence them as needed.
+
+if sys.platform == 'win32':
+ extra_compile_args = [] # no obvious -Werror equivalent on MSVC
+else:
+ if (sys.platform == 'darwin' and
+ [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
+ # assume a standard clang or gcc
+ extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
+ '-Wno-unreachable-code']
+ # special things for clang
+ extra_compile_args.append('-Qunused-arguments')
+ else:
+ # assume a standard gcc
+ extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
+ '-Wno-unused-parameter',
+ '-Wno-unreachable-code']