Index: llvm/test/tools/UpdateTestChecks/lit.local.cfg =================================================================== --- llvm/test/tools/UpdateTestChecks/lit.local.cfg +++ llvm/test/tools/UpdateTestChecks/lit.local.cfg @@ -16,7 +16,8 @@ script_path = os.path.join(config.llvm_src_root, 'utils', name[1:] + '.py') assert os.path.isfile(script_path) config.substitutions.append( - (name, "'%s' %s %s" % (python_exe, script_path, extra_args))) + (name, "'%s' %s %s" % ( + config.python_executable, script_path, extra_args))) config.test_format = lit.formats.ShTest(execute_external=False) @@ -43,20 +44,12 @@ mca_arg = '--llvm-mca-binary ' + shell_quote(llvm_mca_path) add_update_script_substition('%update_test_checks', extra_args=mca_arg) -# update_cc_test_checks requires python3 -py3_exe = lit.util.which('python3') -if py3_exe: - config.substitutions.append(('%python3', shell_quote(py3_exe))) - config.available_features.add('python3') - clang_path = os.path.join(config.llvm_tools_dir, 'clang') if os.path.isfile(clang_path): config.available_features.add('clang-binary') - if py3_exe: - # XXX: or use --llvm-bin? - extra_args = '--clang ' + shell_quote(clang_path) - if os.path.isfile(opt_path): - extra_args += ' --opt ' + shell_quote(opt_path) - add_update_script_substition('%update_cc_test_checks', - python_exe=py3_exe, - extra_args=extra_args) + # XXX: or use --llvm-bin? + extra_args = '--clang ' + shell_quote(clang_path) + if os.path.isfile(opt_path): + extra_args += ' --opt ' + shell_quote(opt_path) + add_update_script_substition('%update_cc_test_checks', + extra_args=extra_args) Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test =================================================================== --- llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test +++ llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test @@ -1,10 +1,6 @@ ## Basic test checking that update_cc_test_checks.py works as expected for ## functions with mangled names -# %update_cc_test_checks is only set if python3 is on the path. -# FIXME: Is this the best approach? See discussion on D70660. -# REQUIRES: python3 - # RUN: cp -f %S/Inputs/mangled_names.c %t.c && %update_cc_test_checks -v %t.c # RUN: diff -u %t.c %S/Inputs/mangled_names.c.expected ## Check that running the script again does not change the result: Index: llvm/utils/update_cc_test_checks.py =================================================================== --- llvm/utils/update_cc_test_checks.py +++ llvm/utils/update_cc_test_checks.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python '''A utility to update LLVM IR CHECK lines in C/C++ FileCheck test files. Example RUN lines in .c/.cc test files: @@ -12,6 +12,8 @@ % utils/update_cc_test_checks.py --clang=release/bin/clang /tmp/c/a.cc ''' +from __future__ import print_function + import argparse import collections import distutils.spawn @@ -37,18 +39,21 @@ def get_line2spell_and_mangled(args, clang_args): ret = {} # Use clang's JSON AST dump to get the mangled name - json_dump_args = [args.clang, *clang_args, '-fsyntax-only', '-o', '-'] + json_dump_args = [args.clang] + clang_args + ['-fsyntax-only', '-o', '-'] if '-cc1' not in json_dump_args: # For tests that invoke %clang instead if %clang_cc1 we have to use # -Xclang -ast-dump=json instead: json_dump_args.append('-Xclang') json_dump_args.append('-ast-dump=json') common.debug('Running', ' '.join(json_dump_args)) - status = subprocess.run(json_dump_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if status.returncode != 0: + + popen = subprocess.Popen(json_dump_args, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, universal_newlines=True) + stdout, stderr = popen.communicate() + if popen.returncode != 0: sys.stderr.write('Failed to run ' + ' '.join(json_dump_args) + '\n') - sys.stderr.write(status.stderr.decode()) - sys.stderr.write(status.stdout.decode()) + sys.stderr.write(stderr) + sys.stderr.write(stdout) sys.exit(2) # Parse the clang JSON and add all children of type FunctionDecl. @@ -75,7 +80,7 @@ mangled = node.get('mangledName', spell) ret[int(line)-1] = (spell, mangled) - ast = json.loads(status.stdout.decode()) + ast = json.loads(stdout) if ast['kind'] != 'TranslationUnitDecl': common.error('Clang AST dump JSON format changed?') sys.exit(2)