Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 205f972

Browse files
authored
Merge pull request #81 from compnerd/substitute
utils: add a helper class to lit for captured substitutions
2 parents a3e2d47 + 1eeb11c commit 205f972

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

utils/lit/lit/TestingConfig.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,22 @@ def root(self):
152152
else:
153153
return self.parent.root
154154

155+
class SubstituteCaptures:
156+
"""
157+
Helper class to indicate that the substitutions contains backreferences.
158+
159+
This can be used as the following in lit.cfg to mark subsitutions as having
160+
back-references::
161+
162+
config.substutions.append(('\b[^ ]*.cpp', SubstituteCaptures('\0.txt')))
163+
164+
"""
165+
def __init__(self, substitution):
166+
self.substitution = substitution
167+
168+
def replace(self, pattern, replacement):
169+
return self.substitution
170+
171+
def __str__(self):
172+
return self.substitution
173+

0 commit comments

Comments
 (0)