51 lines
2.6 KiB
INI
51 lines
2.6 KiB
INI
import lit.formats
|
|
config.name = 'shtest-define'
|
|
config.suffixes = ['.txt']
|
|
# Use lit's internal shell to avoid shell portability issues within RUN lines
|
|
# (e.g., for 'echo' commands in Windows). Those issues should be orthogonal to
|
|
# the substitution behavior we are trying to test.
|
|
config.test_format = lit.formats.ShTest(execute_external=False)
|
|
config.test_source_root = None
|
|
config.test_exec_root = None
|
|
|
|
# When config.recursiveExpansionLimit is not specified, it's important to
|
|
# prepend substitutions before substitutions they might now or later (upon a
|
|
# redefinition) depend upon. For example, %{global:greeting} and %{global:what}
|
|
# act as parameters for %{global:echo}, so we make sure the latter expands
|
|
# before the former. Moreover, some tests redefine %{global:greeting} in terms
|
|
# of %{global:what}, so we make sure the former expands before the latter.
|
|
# If we always insert at the beginning of the substitution list (as DEFINE
|
|
# does), then the rule is simple: define a substitution before you refer to it.
|
|
config.substitutions.insert(0, ('%{global:what}', 'World'))
|
|
config.substitutions.insert(0, ('%{global:greeting}', ''))
|
|
config.substitutions.insert(0,
|
|
('%{global:echo}', "echo GLOBAL: %{global:greeting} %{global:what}"))
|
|
|
|
# The following substitution definitions are confusing and should be avoided.
|
|
# We define them here so we can test that 'DEFINE:' and 'REDEFINE:' directives
|
|
# guard against the confusion they cause.
|
|
|
|
# Even though each of '%{global:inside}', '%{global:prefix}', and
|
|
# '%{global:suffix}' is not already the exact pattern of a substitution,
|
|
# 'DEFINE:' and 'REDEFINE:' will refuse to (re)define a substitution with that
|
|
# pattern because it is a substring of one of the following substitution's
|
|
# patterns.
|
|
config.substitutions.insert(0, ('<%{global:inside}>', '<@>'))
|
|
config.substitutions.insert(0, (r'%{global:prefix}\((.*)\)', r'@(\g<1>)'))
|
|
config.substitutions.insert(0, ('@%{global:suffix}', '@@'))
|
|
|
|
# These cannot be redefined by 'REDEFINE:', which doesn't know which one to
|
|
# redefine.
|
|
config.substitutions.insert(0, ('%{global:multiple-exact}', 'first'))
|
|
config.substitutions.insert(0, ('%{global:multiple-exact}', 'second'))
|
|
|
|
# Even though '%{global:multiple-once-exact}' is the exact pattern of only one
|
|
# existing substitution, 'REDEFINE:' will refuse to redefine that substitution
|
|
# because that string is a substring of another substitution's pattern.
|
|
config.substitutions.insert(0, ('%{global:multiple-once-exact}', '@'))
|
|
config.substitutions.insert(0, ('<%{global:multiple-once-exact}>', '<@>'))
|
|
|
|
recur = lit_config.params.get('recur', None)
|
|
if recur:
|
|
config.recursiveExpansionLimit = int(recur)
|