summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2012-11-14 20:26:19 +0000
committerAlexander Kornienko <alexfh@google.com>2012-11-14 20:26:19 +0000
commit08639983ded4250c18614c62450e70ba653aac4c (patch)
tree59a6610eabf04c4aca104d5a080c99dfb85bf134 /utils
parent984639b7a4b2e2f15d82d64623a634b4772f022f (diff)
downloadllvm-08639983ded4250c18614c62450e70ba653aac4c.tar.gz
llvm-08639983ded4250c18614c62450e70ba653aac4c.tar.bz2
llvm-08639983ded4250c18614c62450e70ba653aac4c.tar.xz
Added %(line), %(line+<number>), %(line-<number>) substitutions to lit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/TestRunner.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index 0c1911ed35..e339652f83 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -432,7 +432,9 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
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:')
@@ -441,6 +443,15 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
# 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