| 1 | import os |
| 2 | import glob |
| 3 | |
| 4 | import lit.util |
| 5 | |
| 6 | # python 2.7 backwards compatibility |
| 7 | try: |
| 8 | from shlex import quote as shell_quote |
| 9 | except ImportError: |
| 10 | from pipes import quote as shell_quote |
| 11 | |
| 12 | |
| 13 | if config.standalone_build: |
| 14 | # These tests require the update_cc_test_checks.py script from the llvm |
| 15 | # source tree, so skip these tests if we are doing standalone builds. |
| 16 | # These tests are only relevant to developers working with the |
| 17 | # update_cc_test_checks.py tool; they don't provide any coverage |
| 18 | # for any of the clang source code. |
| 19 | config.unsupported = True |
| 20 | else: |
| 21 | |
| 22 | config.test_format = lit.formats.ShTest(execute_external=False) |
| 23 | config.suffixes = [".test"] |
| 24 | |
| 25 | clang_path = os.path.join(config.clang_tools_dir, "clang") |
| 26 | extra_args = "--clang " + shell_quote(clang_path) |
| 27 | opt_path = os.path.join(config.llvm_tools_dir, "opt") |
| 28 | extra_args += " --opt " + shell_quote(opt_path) |
| 29 | # Specify an explicit default version in UTC tests, so that the --version |
| 30 | # embedded in UTC_ARGS does not change in all test expectations every time |
| 31 | # the default is bumped. |
| 32 | extra_args += " --version=1" |
| 33 | script_path = os.path.join( |
| 34 | config.llvm_src_root, "utils", "update_cc_test_checks.py" |
| 35 | ) |
| 36 | assert os.path.isfile(script_path) |
| 37 | # Windows: llvm-lit.py, Linux: llvm-lit |
| 38 | if config.llvm_external_lit: |
| 39 | lit = config.llvm_external_lit |
| 40 | else: |
| 41 | lit = shell_quote( |
| 42 | glob.glob(os.path.join(config.llvm_tools_dir, "llvm-lit*"))[0] |
| 43 | ) |
| 44 | python = shell_quote(config.python_executable) |
| 45 | config.substitutions.append( |
| 46 | ( |
| 47 | "%update_cc_test_checks", |
| 48 | "%s %s %s" % (python, shell_quote(script_path), extra_args), |
| 49 | ) |
| 50 | ) |
| 51 | config.substitutions.append( |
| 52 | ("%clang_tools_dir", shell_quote(config.clang_tools_dir)) |
| 53 | ) |
| 54 | config.substitutions.append( |
| 55 | ( |
| 56 | "%lit", |
| 57 | "%s %s -Dclang_lit_site_cfg=%s -j1 -vv" |
| 58 | % (python, lit, shell_quote(config.clang_lit_site_cfg)), |
| 59 | ) |
| 60 | ) |