[PATCH] D53798: [lit] Add --show-substitutions
Eugene Sharygin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 28 05:07:08 PDT 2018
eush created this revision.
eush added reviewers: atrick, delcypher, rnk.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D53798
Files:
utils/lit/lit/main.py
utils/lit/tests/Inputs/show-substitutions/lit.cfg
utils/lit/tests/Inputs/show-substitutions/test.txt
utils/lit/tests/show-substitutions.py
Index: utils/lit/tests/show-substitutions.py
===================================================================
--- /dev/null
+++ utils/lit/tests/show-substitutions.py
@@ -0,0 +1,8 @@
+# RUN: %{lit} --show-substitutions %{inputs}/show-substitutions | FileCheck %s
+
+# CHECK: Substitutions
+# CHECK-NEXT: %foo = foo
+# CHECK-NEXT: %foo = ''
+# CHECK-NEXT: \|%lli\b(?!(\.)) = /bin/lli
+# CHECK-NEXT: '\\| not' = '/bin/not '
+# CHECK-NEXT: "'foo'" = '"foo"'
Index: utils/lit/tests/Inputs/show-substitutions/test.txt
===================================================================
--- /dev/null
+++ utils/lit/tests/Inputs/show-substitutions/test.txt
@@ -0,0 +1 @@
+# RUN: true
Index: utils/lit/tests/Inputs/show-substitutions/lit.cfg
===================================================================
--- /dev/null
+++ utils/lit/tests/Inputs/show-substitutions/lit.cfg
@@ -0,0 +1,13 @@
+import lit.formats
+
+config.name = 'shtest-shell'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+
+config.substitutions = [('%foo', 'foo'),
+ ('%foo', ''),
+ (r'\|%lli\b(?!(\.))', '/bin/lli'),
+ (r'\| not', '/bin/not '),
+ ("'foo'", '"foo"')]
Index: utils/lit/lit/main.py
===================================================================
--- utils/lit/lit/main.py
+++ utils/lit/lit/main.py
@@ -321,6 +321,9 @@
debug_group.add_argument("--show-tests", dest="showTests",
help="Show all discovered tests",
action="store_true", default=False)
+ debug_group.add_argument("--show-substitutions", dest="showSubstitutions",
+ help="Show all substitutions (implies --show-suites)",
+ action="store_true", default=False)
debug_group.add_argument("--single-process", dest="singleProcess",
help="Don't run tests in parallel. Intended for debugging "
"single test failures",
@@ -345,6 +348,9 @@
if opts.echoAllCommands:
opts.showOutput = True
+ if opts.showSubstitutions:
+ opts.showSuites = True
+
inputs = args
# Create the user defined parameters.
@@ -421,6 +427,14 @@
if ts.config.available_features:
print(' Available Features : %s' % ' '.join(
sorted(ts.config.available_features)))
+ if opts.showSubstitutions and ts.config.substitutions:
+ print(' Substitutions')
+ for (pattern, replacement) in ts.config.substitutions:
+ if re.match(r'[\'"]|.*\s', pattern):
+ pattern = repr(pattern)
+ if re.match(r'[\'"]|.*\s|$', replacement):
+ replacement = repr(replacement)
+ print(' %s = %s' %(pattern, replacement))
# Show the tests, if requested.
if opts.showTests:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53798.171420.patch
Type: text/x-patch
Size: 3085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181028/0c682b5f/attachment.bin>
More information about the llvm-commits
mailing list