[lld] r255283 - Make commands printed by llvm-lit include the build path in lit.cfg.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 11:17:35 PST 2015


Author: pete
Date: Thu Dec 10 13:17:35 2015
New Revision: 255283

URL: http://llvm.org/viewvc/llvm-project?rev=255283&view=rev
Log:
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

Modified:
    lld/trunk/test/lit.cfg

Modified: lld/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/lit.cfg?rev=255283&r1=255282&r2=255283&view=diff
==============================================================================
--- lld/trunk/test/lit.cfg (original)
+++ lld/trunk/test/lit.cfg Thu Dec 10 13:17:35 2015
@@ -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:




More information about the llvm-commits mailing list