<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">Daniel, any thoughts on this?<br><br><div class="gmail_quote">On Thu, Nov 8, 2012 at 1:43 AM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi ddunbar, doug.gregor,<br>
<br>
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/).<br>
<br>
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.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D105" target="_blank">http://llvm-reviews.chandlerc.com/D105</a><br>
<br>
Files:<br>
utils/lit/lit/TestRunner.py<br>
<br>
Index: utils/lit/lit/TestRunner.py<br>
===================================================================<br>
--- utils/lit/lit/TestRunner.py<br>
+++ utils/lit/lit/TestRunner.py<br>
@@ -432,15 +432,26 @@<br>
script = []<br>
xfails = []<br>
requires = []<br>
+ line_number = 0<br>
for ln in open(sourcepath):<br>
+ line_number += 1<br>
if 'RUN:' in ln:<br>
# Isolate the command to run.<br>
index = ln.index('RUN:')<br>
ln = ln[index+4:]<br>
<br>
# Trim trailing whitespace.<br>
ln = ln.rstrip()<br>
<br>
+ # Substitute line number expressions<br>
+ ln = re.sub('%\(line\)', str(line_number), ln)<br>
+ def replace_line_number(match):<br>
+ if match.group(1) == '+':<br>
+ return str(line_number + int(match.group(2)))<br>
+ if match.group(1) == '-':<br>
+ return str(line_number - int(match.group(2)))<br>
+ ln = re.sub('%\(line *([\+-]) *(\d+)\)', replace_line_number, ln)<br>
+<br>
# Collapse lines with trailing '\\'.<br>
if script and script[-1][-1] == '\\':<br>
script[-1] = script[-1][:-1] + ln<br>
</blockquote></div><br>
</div>