[cfe-commits] [PATCH] Added %(line), %(line+<number>), %(line-<number>) substitutions to lit
Alexander Kornienko
alexfh at google.com
Mon Nov 12 16:42:22 PST 2012
Daniel, any thoughts on this?
On Thu, Nov 8, 2012 at 1:43 AM, Alexander Kornienko <alexfh at google.com>wrote:
> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121113/56f16129/attachment.html>
More information about the cfe-commits
mailing list