[cfe-commits] [PATCH] Added %(line), %(line+<number>), %(line-<number>) substitutions to lit
Alexander Kornienko
alexfh at google.com
Wed Nov 7 16:43:49 PST 2012
Hi ddunbar, doug.gregor,
This will help make more supportable tests, that specify source file line number in RUN: lines (most tests in tools/clang/test/Index/ and tools/clang/test/CodeCompletion/).
With this substitution it's easier to insert/remove/move lines in test files without breaking fragile connection between RUN: lines and test file contents.
http://llvm-reviews.chandlerc.com/D105
Files:
utils/lit/lit/TestRunner.py
Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -432,15 +432,26 @@
script = []
xfails = []
requires = []
+ line_number = 0
for ln in open(sourcepath):
+ line_number += 1
if 'RUN:' in ln:
# Isolate the command to run.
index = ln.index('RUN:')
ln = ln[index+4:]
# Trim trailing whitespace.
ln = ln.rstrip()
+ # Substitute line number expressions
+ ln = re.sub('%\(line\)', str(line_number), ln)
+ def replace_line_number(match):
+ if match.group(1) == '+':
+ return str(line_number + int(match.group(2)))
+ if match.group(1) == '-':
+ return str(line_number - int(match.group(2)))
+ ln = re.sub('%\(line *([\+-]) *(\d+)\)', replace_line_number, ln)
+
# Collapse lines with trailing '\\'.
if script and script[-1][-1] == '\\':
script[-1] = script[-1][:-1] + ln
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105.1.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121107/2dbd3bf6/attachment.bin>
More information about the cfe-commits
mailing list