r204493 - Make clang/test/lit.cfg pre-scan the RUN line looking for tool names,

Paul Robinson paul_robinson at playstation.sony.com
Fri Mar 21 11:13:35 PDT 2014


Author: probinson
Date: Fri Mar 21 13:13:35 2014
New Revision: 204493

URL: http://llvm.org/viewvc/llvm-project?rev=204493&view=rev
Log:
Make clang/test/lit.cfg pre-scan the RUN line looking for tool names,
and substitute fully qualified path names pointing to the build
directory.  This ensures we're testing the just-built tools.

Modified:
    cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=204493&r1=204492&r2=204493&view=diff
==============================================================================
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Fri Mar 21 13:13:35 2014
@@ -288,6 +288,40 @@ config.substitutions.append(
     (' %clang-cl ',
      """*** invalid substitution, use '%clang_cl'. ***""") )
 
+# For each occurrence of a clang 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.
+# For example, don't match 'clang-check-' or '.clang-format'.
+# Regex assertions to reject neighbor hyphens/dots (seen in some tests).
+NoPreHyphenDot = r"(?<!(-|\.))"
+NoPostHyphenDot = r"(?!(-|\.))"
+
+for pattern in [r"\bFileCheck\b",
+                r"\bc-index-test\b",
+                NoPreHyphenDot + r"\bclang-check\b" + NoPostHyphenDot,
+                NoPreHyphenDot + r"\bclang-format\b" + NoPostHyphenDot,
+                # FIXME: Some clang test uses opt?
+                NoPreHyphenDot + r"\bopt\b" + NoPostHyphenDot,
+                # Handle these specially as they are strings searched
+                # for during testing.
+                r"\| \bcount\b",
+                r"\| \bnot\b"]:
+    # 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))
+
 ###
 
 # Set available features we allow tests to conditionalize on.





More information about the cfe-commits mailing list