diff options
Diffstat (limited to 'runtests.py')
-rwxr-xr-x | runtests.py | 119 |
1 files changed, 70 insertions, 49 deletions
diff --git a/runtests.py b/runtests.py index 72608882a..7b0b74c30 100755 --- a/runtests.py +++ b/runtests.py @@ -294,57 +294,60 @@ def update_openmp_extension(ext): return EXCLUDE_EXT -def update_cpp11_extension(ext): - """ - update cpp11 extensions that will run on versions of gcc >4.8 - """ - gcc_version = get_gcc_version(ext.language) - already_has_std = any(ca for ca in ext.extra_compile_args if "-std" in ca) - if gcc_version: - compiler_version = gcc_version.group(1) - if float(compiler_version) > 4.8 and not already_has_std: - ext.extra_compile_args.append("-std=c++11") - return ext +def update_cpp_extension(cpp_std, min_gcc_version=None, min_clang_version=None, min_macos_version=None): + def _update_cpp_extension(ext): + """ + Update cpp[cpp_std] extensions that will run on minimum versions of gcc / clang / macos. + """ + # If the extension provides a -std=... option, assume that whatever C compiler we use + # will probably be ok with it. + already_has_std = any( + ca for ca in ext.extra_compile_args + if "-std" in ca and "-stdlib" not in ca + ) + use_gcc = use_clang = already_has_std - clang_version = get_clang_version(ext.language) - if clang_version: - if not already_has_std: - ext.extra_compile_args.append("-std=c++11") - if sys.platform == "darwin": - ext.extra_compile_args.append("-stdlib=libc++") - ext.extra_compile_args.append("-mmacosx-version-min=10.7") - return ext + # check for a usable gcc version + gcc_version = get_gcc_version(ext.language) + if gcc_version: + if cpp_std >= 17 and sys.version_info[0] < 3: + # The Python 2.7 headers contain the 'register' modifier + # which gcc warns about in C++17 mode. + ext.extra_compile_args.append('-Wno-register') + if not already_has_std: + compiler_version = gcc_version.group(1) + if not min_gcc_version or float(compiler_version) >= float(min_gcc_version): + use_gcc = True + ext.extra_compile_args.append("-std=c++%s" % cpp_std) + + if use_gcc: + return ext - return EXCLUDE_EXT + # check for a usable clang version + clang_version = get_clang_version(ext.language) + if clang_version: + if cpp_std >= 17 and sys.version_info[0] < 3: + # The Python 2.7 headers contain the 'register' modifier + # which clang warns about in C++17 mode. + ext.extra_compile_args.append('-Wno-register') + if not already_has_std: + compiler_version = clang_version.group(1) + if not min_clang_version or float(compiler_version) >= float(min_clang_version): + use_clang = True + ext.extra_compile_args.append("-std=c++%s" % cpp_std) + if sys.platform == "darwin": + ext.extra_compile_args.append("-stdlib=libc++") + if min_macos_version is not None: + ext.extra_compile_args.append("-mmacosx-version-min=" + min_macos_version) + + if use_clang: + return ext -def update_cpp17_extension(ext): - """ - update cpp17 extensions that will run on versions of gcc >=5.0 - """ - gcc_version = get_gcc_version(ext.language) - if gcc_version: - compiler_version = gcc_version.group(1) - if sys.version_info[0] < 3: - # The Python 2.7 headers contain the 'register' modifier - # which gcc warns about in C++17 mode. - ext.extra_compile_args.append('-Wno-register') - if float(compiler_version) >= 5.0: - ext.extra_compile_args.append("-std=c++17") - return ext + # no usable C compiler found => exclude the extension + return EXCLUDE_EXT - clang_version = get_clang_version(ext.language) - if clang_version: - ext.extra_compile_args.append("-std=c++17") - if sys.version_info[0] < 3: - # The Python 2.7 headers contain the 'register' modifier - # which clang warns about in C++17 mode. - ext.extra_compile_args.append('-Wno-register') - if sys.platform == "darwin": - ext.extra_compile_args.append("-stdlib=libc++") - ext.extra_compile_args.append("-mmacosx-version-min=10.13") - return ext + return _update_cpp_extension - return EXCLUDE_EXT def require_gcc(version): def check(ext): @@ -438,8 +441,9 @@ EXT_EXTRAS = { 'tag:numpy' : update_numpy_extension, 'tag:openmp': update_openmp_extension, 'tag:gdb': update_gdb_extension, - 'tag:cpp11': update_cpp11_extension, - 'tag:cpp17': update_cpp17_extension, + 'tag:cpp11': update_cpp_extension(11, min_gcc_version="4.9", min_macos_version="10.7"), + 'tag:cpp17': update_cpp_extension(17, min_gcc_version="5.0", min_macos_version="10.13"), + 'tag:cpp20': update_cpp_extension(20, min_gcc_version="11.0", min_clang_version="13.0", min_macos_version="10.13"), 'tag:trace' : update_linetrace_extension, 'tag:bytesformat': exclude_extension_in_pyver((3, 3), (3, 4)), # no %-bytes formatting 'tag:no-macos': exclude_extension_on_platform('darwin'), @@ -467,6 +471,7 @@ VER_DEP_MODULES = { 'compile.extsetslice', 'compile.extdelslice', 'run.special_methods_T561_py2', + 'run.builtin_type_inheritance_T608_py2only', ]), (3,3) : (operator.lt, lambda x: x in ['build.package_compilation', 'build.cythonize_pep420_namespace', @@ -477,6 +482,7 @@ VER_DEP_MODULES = { (3,4): (operator.lt, lambda x: x in ['run.py34_signature', 'run.test_unicode', # taken from Py3.7, difficult to backport 'run.pep442_tp_finalize', + 'run.pep442_tp_finalize_cimport', ]), (3,4,999): (operator.gt, lambda x: x in ['run.initial_file_path', ]), @@ -491,6 +497,7 @@ VER_DEP_MODULES = { ]), (3,7): (operator.lt, lambda x: x in ['run.pycontextvar', 'run.pep557_dataclasses', # dataclasses module + 'run.test_dataclasses', ]), } @@ -1426,6 +1433,8 @@ class CythonCompileTestCase(unittest.TestCase): def _match_output(self, expected_output, actual_output, write): try: for expected, actual in zip(expected_output, actual_output): + if expected != actual and '\\' in actual and os.sep == '\\' and '/' in expected and '\\' not in expected: + expected = expected.replace('/', '\\') self.assertEqual(expected, actual) if len(actual_output) < len(expected_output): expected = expected_output[len(actual_output)] @@ -1926,6 +1935,8 @@ class EndToEndTest(unittest.TestCase): os.chdir(self.old_dir) def _try_decode(self, content): + if not isinstance(content, bytes): + return content try: return content.decode() except UnicodeDecodeError: @@ -1965,6 +1976,10 @@ class EndToEndTest(unittest.TestCase): for c, o, e in zip(cmd, out, err): sys.stderr.write("[%d] %s\n%s\n%s\n\n" % ( self.shard_num, c, self._try_decode(o), self._try_decode(e))) + sys.stderr.write("Final directory layout of '%s':\n%s\n\n" % ( + self.name, + '\n'.join(os.path.join(dirpath, filename) for dirpath, dirs, files in os.walk(".") for filename in files), + )) self.assertEqual(0, res, "non-zero exit status, last output was:\n%r\n-- stdout:%s\n-- stderr:%s\n" % ( ' '.join(command), self._try_decode(out[-1]), self._try_decode(err[-1]))) self.success = True @@ -2531,12 +2546,17 @@ def configure_cython(options): CompilationOptions, \ default_options as pyrex_default_options from Cython.Compiler.Options import _directive_defaults as directive_defaults + from Cython.Compiler import Errors Errors.LEVEL = 0 # show all warnings + from Cython.Compiler import Options Options.generate_cleanup_code = 3 # complete cleanup code + from Cython.Compiler import DebugFlags DebugFlags.debug_temp_code_comments = 1 + DebugFlags.debug_no_exception_intercept = 1 # provide better crash output in CI runs + pyrex_default_options['formal_grammar'] = options.use_formal_grammar if options.profile: directive_defaults['profile'] = True @@ -2701,7 +2721,8 @@ def runtests(options, cmd_args, coverage=None): ('graal_bugs.txt', IS_GRAAL), ('limited_api_bugs.txt', options.limited_api), ('windows_bugs.txt', sys.platform == 'win32'), - ('cygwin_bugs.txt', sys.platform == 'cygwin') + ('cygwin_bugs.txt', sys.platform == 'cygwin'), + ('windows_bugs_39.txt', sys.platform == 'win32' and sys.version_info[:2] == (3, 9)) ] exclude_selectors += [ |