Only run mangled_names.test if python3 is available.

The %update_cc_test_checks substitution only gets added if python3
is on path, so the test fails if it isn't. Don't run the test
when it would fail.

Also include the '%' in the arg to add_update_script_substition(),
to help greppability.
This commit is contained in:
Nico Weber 2019-12-16 14:26:31 -05:00
parent ee912fe6a1
commit cc802ea67b
2 changed files with 14 additions and 8 deletions

View File

@ -12,10 +12,11 @@ except ImportError:
def add_update_script_substition(name, python_exe=config.python_executable,
extra_args=''):
script_path = os.path.join(config.llvm_src_root, 'utils', name + '.py')
assert name.startswith('%')
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" % (python_exe, script_path, extra_args)))
config.test_format = lit.formats.ShTest(execute_external=False)
@ -25,22 +26,22 @@ llc_path = os.path.join(config.llvm_tools_dir, 'llc')
if os.path.isfile(llc_path):
config.available_features.add('llc-binary')
llc_arg = '--llc-binary ' + shell_quote(llc_path)
add_update_script_substition('update_llc_test_checks', extra_args=llc_arg)
add_update_script_substition('update_mir_test_checks', extra_args=llc_arg)
add_update_script_substition('%update_llc_test_checks', extra_args=llc_arg)
add_update_script_substition('%update_mir_test_checks', extra_args=llc_arg)
opt_path = os.path.join(config.llvm_tools_dir, 'opt')
if os.path.isfile(opt_path):
config.available_features.add('opt-binary')
opt_arg = '--opt-binary ' + shell_quote(opt_path)
add_update_script_substition('update_test_checks', extra_args=opt_arg)
add_update_script_substition('update_analyze_test_checks',
add_update_script_substition('%update_test_checks', extra_args=opt_arg)
add_update_script_substition('%update_analyze_test_checks',
extra_args=opt_arg)
llvm_mca_path = os.path.join(config.llvm_tools_dir, 'llvm-mca')
if os.path.isfile(llvm_mca_path):
config.available_features.add('llvm-mca-binary')
mca_arg = '--llvm-mca-binary ' + shell_quote(llvm_mca_path)
add_update_script_substition('update_test_checks', extra_args=mca_arg)
add_update_script_substition('%update_test_checks', extra_args=mca_arg)
# update_cc_test_checks requires python3
py3_exe = lit.util.which('python3')
@ -56,6 +57,6 @@ if os.path.isfile(clang_path):
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',
add_update_script_substition('%update_cc_test_checks',
python_exe=py3_exe,
extra_args=extra_args)

View File

@ -1,5 +1,10 @@
## 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: