diff options
author | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-11-17 09:01:58 +0100 |
---|---|---|
committer | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-11-17 09:01:58 +0100 |
commit | 56758354c8dec21792aeddb9ade4ea5072a7e1a2 (patch) | |
tree | aaef673eb0c4b4ccccb20a3847198f4fa34ae9d0 /Lib/test | |
parent | b7a45d448e80e6f14c28a492c99b9d25171d6f74 (diff) | |
parent | dfc13e069a0ff2dedce0096a85335755aecec4a3 (diff) | |
download | cpython-git-56758354c8dec21792aeddb9ade4ea5072a7e1a2.tar.gz |
Issue 26931: Merge 3.6
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/support/__init__.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 81136100f0..f10672383e 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -105,7 +105,7 @@ __all__ = [ "check_warnings", "check_no_resource_warning", "EnvironmentVarGuard", "run_with_locale", "swap_item", "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", - "run_with_tz", "PGO", + "run_with_tz", "PGO", "missing_compiler_executable", ] class Error(Exception): @@ -2491,3 +2491,28 @@ def check_free_after_iterating(test, iter, cls, args=()): # The sequence should be deallocated just after the end of iterating gc_collect() test.assertTrue(done) + + +def missing_compiler_executable(cmd_names=[]): + """Check if the compiler components used to build the interpreter exist. + + Check for the existence of the compiler executables whose names are listed + in 'cmd_names' or all the compiler executables when 'cmd_names' is empty + and return the first missing executable or None when none is found + missing. + + """ + from distutils import ccompiler, sysconfig, spawn + compiler = ccompiler.new_compiler() + sysconfig.customize_compiler(compiler) + for name in compiler.executables: + if cmd_names and name not in cmd_names: + continue + cmd = getattr(compiler, name) + if cmd_names: + assert cmd is not None, \ + "the '%s' executable is not configured" % name + elif cmd is None: + continue + if spawn.find_executable(cmd[0]) is None: + return cmd[0] |