Make commands printed by llvm-lit include the build path in lit.cfg.

When llvm-lit prints a failure, you'll see something like 'lld *command*' However, you can't then take this, paste it in to a terminal and run it, because it's not got the absolute path of lld.

llvm and clang's lit.cfg files contain lists of commands to look for which are substituted by their full paths. So now you'd see something like '*build dir*/bin/lld *command*'.

This patch adds the same capability to lld's lit.cfg

Reviewed by Rafael Espíndola

llvm-svn: 255283
This commit is contained in:
Pete Cooper 2015-12-10 19:17:35 +00:00
parent ccfc3261f3
commit 80c9b9468f
1 changed files with 40 additions and 0 deletions

View File

@ -139,6 +139,46 @@ if config.test_exec_root is None:
lit_config.load_config(config, site_cfg)
raise SystemExit
# For each occurrence of a lld tool name as its own word, replace it
# with the full path to the build directory holding that tool. This
# ensures that we are testing the tools just built and not some random
# tools that might happen to be in the user's PATH.
# Regex assertions to reject neighbor hyphens/dots (seen in some tests).
# For example, we want to prefix 'lld' and 'ld.lld' but not the 'lld' inside
# of 'ld.lld'.
NoPreHyphenDot = r"(?<!(-|\.))"
NoPostHyphenDot = r"(?!(-|\.))"
tool_patterns = [r"\bFileCheck\b",
r"\bnot\b",
NoPreHyphenDot + r"\blld\b" + NoPostHyphenDot,
r"\bld.lld\b",
r"\blld-link\b",
r"\bllvm-mc\b",
r"\bllvm-nm\b",
r"\bllvm-objdump\b",
r"\bllvm-readobj\b",
r"\byaml2obj\b"]
for pattern in tool_patterns:
# Extract the tool name from the pattern. This relies on the tool
# name being surrounded by \b word match operators. If the
# pattern starts with "| ", include it in the string to be
# substituted.
tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_\.]+)\\b\W*$",
pattern)
tool_pipe = tool_match.group(2)
tool_name = tool_match.group(4)
tool_path = lit.util.which(tool_name, llvm_tools_dir)
if not tool_path:
# Warn, but still provide a substitution.
lit_config.note('Did not find ' + tool_name + ' in ' + llvm_tools_dir)
tool_path = llvm_tools_dir + '/' + tool_name
config.substitutions.append((pattern, tool_pipe + tool_path))
###
# When running under valgrind, we mangle '-vg' onto the end of the triple so we
# can check it with XFAIL and XTARGET.
if lit_config.useValgrind: