llvm.org GIT mirror llvm / 18d4987
Reapply 122341 to fix PR8199 now that clang changes are in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122754 91177308-0d34-0410-b5e6-96231b3b80d8 David Greene 8 years ago
3 changed file(s) with 50 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
375375 shell. Consequently the syntax differs from normal shell script syntax in a
376376 few ways. You can specify as many RUN lines as needed.

377377
378

lit performs substitution on each RUN line to replace LLVM tool

379 names with the full paths to the executable built for each tool (in
380 $(LLVM_OBJ_ROOT)/$(BuildMode)/bin). This ensures that lit does not
381 invoke any stray LLVM tools in the user's path during testing.

382
378383

Each RUN line is executed on its own, distinct from other lines unless

379384 its last character is \. This continuation character causes the RUN
380385 line to be concatenated with the next one. In this way you can build up long
33
44 import os
55 import sys
6 import re
67
78 # name: The name of this test suite.
89 config.name = 'LLVM'
147148 else:
148149 config.substitutions.append(('%' + sub, site_exp[sub]))
149150
151 # For each occurrence of an llvm tool name as its own word, replace it
152 # with the full path to the build directory holding that tool. This
153 # ensures that we are testing the tools just built and not some random
154 # tools that might happen to be in the user's PATH. Thus this list
155 # includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
156 # (llvm_tools_dir in lit parlance).
157 # Don't match 'bugpoint-'.
158 for pattern in [r"\bbugpoint\b(?!-)", r"\bclang\b",
159 r"\bedis\b", r"\bgold\b",
160 r"\bllc\b", r"\blli\b",
161 r"\bllvm-ar\b", r"\bllvm-as\b",
162 r"\bllvm-bcanalyzer\b", r"\bllvm-config\b",
163 r"\bllvm-diff\b", r"\bllvm-dis\b",
164 r"\bllvm-extract\b", r"\bllvm-ld\b",
165 r"\bllvm-link\b", r"\bllvm-mc\b",
166 r"\bllvm-nm\b", r"\bllvm-prof\b",
167 r"\bllvm-ranlib\b", r"\bllvm-shlib\b",
168 r"\bllvm-stub\b", r"\bllvm2cpp\b",
169 # Don't match '-llvmc'.
170 r"(?
171 # Don't match '.opt', '-opt'
172 # or '^opt'.
173 r"\bmacho-dump\b", r"(?
174 r"\btblgen\b", r"\bFileCheck\b",
175 r"\bFileUpdate\b", r"\bc-index-test\b",
176 r"\bfpcmp\b", r"\bllvm-PerfectShuffle\b",
177 # Handle these specially as they are strings searched
178 # for during testing.
179 r"\| \bcount\b", r"\| \bnot\b"]:
180 # Extract the tool name from the pattern. This relies on the tool
181 # name being surrounded by \b word match operators. If the
182 # pattern starts with "| ", include it in the string to be
183 # substituted.
184 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
185 r"\2" + llvm_tools_dir + "/" + r"\4",
186 pattern)
187 config.substitutions.append((pattern, substitution))
188
150189 excludes = []
151190
152191 # Provide target_triple for use in XFAIL and XTARGET.
66
77 import platform
88 import tempfile
9
10 import re
911
1012 class InternalShellError(Exception):
1113 def __init__(self, command, message):
443445 if ln[ln.index('END.'):].strip() == 'END.':
444446 break
445447
446 # Apply substitutions to the script.
448 # Apply substitutions to the script. Allow full regular
449 # expression syntax. Replace each matching occurrence of regular
450 # expression pattern a with substitution b in line ln.
447451 def processLine(ln):
448452 # Apply substitutions
449453 for a,b in substitutions:
450 ln = ln.replace(a,b)
454 ln = re.sub(a, b, ln)
451455
452456 # Strip the trailing newline and any extra whitespace.
453457 return ln.strip()