[llvm-bugs] [Bug 31237] New: lit substitutions don't work well when a substitution is a prefix of another
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Dec 2 08:08:32 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31237
Bug ID: 31237
Summary: lit substitutions don't work well when a substitution
is a prefix of another
Product: Test Suite
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: lit
Assignee: unassignedbugs at nondot.org
Reporter: dan at su-root.co.uk
CC: daniel at zuster.org, llvm-bugs at lists.llvm.org,
modocache at gmail.com
Classification: Unclassified
I was surprised to find today that lit was doing a substitution for me that I
wasn't expecting. It just so happened to be the "right thing" but this
behaviour could really bite us one day.
Concrete example:
Let's say we have
```
config.substitutions.append(('%klee', '/bin/klee'))
```
in our lit configuration file and we have a test that just contains
```
RUN: not echo %klee-stats
```
The test will fail with something like
```
******************** TEST 'KLEE :: regression/x.c' FAILED ********************
Script:
--
not /bin/klee-stats
--
Exit Code: 1
```
We can see that lit expanded the '%klee' in '%klee-stats'. Okay so I guess this
isn't too surprising but what if the lit configuration was this.
```
config.substitutions.append(('%klee', '/bin/klee'))
config.substitutions.append(('%klee-stats', '/bin/klee'))
```
then lit actually does the same thing it expands the RUN line to
```
not echo /bin/klee-stats
```
lit preferred the `%klee` substitution rather than the `%klee-stats` because it
is early in its list of substitutions than `%klee-stats`.
This might not be the behaviour that the user of lit expected.
I'm not sure the best way to handle this but I would suggest emitting a warning
if one of the user supplied substitutions is a prefix of another and the prefix
appears before the longer string in the list of substitutions to apply.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161202/59e361f5/attachment.html>
More information about the llvm-bugs
mailing list