This is an archive of the discontinued LLVM Phabricator instance.

[lit] Add --show-substitutions
Needs ReviewPublic

Authored by eush on Oct 28 2018, 5:07 AM.

Details

Summary

This adds a flag for llvm-lit to print all substitutions for each discovered
test suite as suggested in http://bugs.llvm.org/show_bug.cgi?id=31609.

This flag can be used to quickly look up all defined substitutions for a
given configuration without diving into Lit configs.

The implementation tries to minimize escaping but also avoid ambiguity, so in
the output quoted keys/values are always escaped, and unquoted keys/values are
always literal.

Diff Detail

Event Timeline

eush created this revision.Oct 28 2018, 5:07 AM
delcypher added inline comments.Nov 1 2018, 6:20 AM
utils/lit/lit/main.py
352

Why is showing substitutions coupled with listing the test suites?

433

Is all this regex really necessary? Couldn't we just always print repr(pattern), repr(replacement)?

eush added inline comments.Nov 1 2018, 6:42 AM
utils/lit/lit/main.py
352

Substitutions are defined per test suite, so we have to list test suites anyway. We could hide some lines though
(such as available features).

433

My only concern is that otherwise it would be harder to read regexes since they would be (doubly) escaped.

delcypher added inline comments.Jan 24 2019, 3:57 AM
utils/lit/lit/main.py
433

Then why even use repr(...)? Just print as a regular string always.

E.g.

>>> print(repr(r'\s\w'))
'\\s\\w'
>>> print(str(r'\s\w'))
\s\w

I honestly don't understand what your regex logic is trying to achieve so I really think you should drop it.

@eush Also sorry for the delay. I just noticed that this patch was in my list of unreviewed patches. Please feel free to ping me on this review if I don't respond in a timely manner.

Thanks for doing this.

Apart from the regexp pretty-printing, this LGTM.

utils/lit/lit/main.py
432

[nits] the parenthesis around the tuple are not needed.

433

I agree with @delcypher . Just printing the pattern « as is » should be fine.

jdenny added a subscriber: jdenny.Apr 15 2020, 6:46 AM

FYI: A similar patch already went in: D77818

serge-sans-paille resigned from this revision.Mar 9 2021, 12:28 AM

This bug should probably be closed then

Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2021, 12:28 AM