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: 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/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/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"'