summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lit
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
commit317adfc8b743d275124497bdf1c72b97d055e938 (patch)
treef7201452360d78a923c7cc4f2c58be03017b9095 /llvm/utils/lit
parente18e4add6c49ddba1547a99ee9231a3428565bb8 (diff)
downloadbcm5719-llvm-317adfc8b743d275124497bdf1c72b97d055e938.tar.gz
bcm5719-llvm-317adfc8b743d275124497bdf1c72b97d055e938.zip
Added %(line), %(line+<number>), %(line-<number>) substitutions to lit
llvm-svn: 167971
Diffstat (limited to 'llvm/utils/lit')
-rw-r--r--llvm/utils/lit/lit/TestRunner.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 0c1911ed356..e339652f834 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/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
OpenPOWER on IntegriCloud