blob: 6613900fb54476c01015a087437e8ede8bcd4d36 [file] [log] [blame]
# Since we try to pass substitutions as-is to some tests, we must "escape"
# them in case they contain other substitutions. Otherwise, the substitutions
# will be fully expanded when passed to the tests. For example, we want an
# %{exec} substitution that contains `--execdir %T` to be passed as-is, without
# substituting the directory. This way, the test itself can populate %T as it
# sees fit, and %{exec} will respect it.
#
# To solve this problem, we add base64 encoded versions of substitutions just
# in this directory. We then base64-decode them from the tests when we need to.
# Another option would be to have a way to prevent expansion in Lit itself.
import base64
import lit.util
base64Encode = lambda s: lit.util.to_string(base64.b64encode(lit.util.to_bytes(s)))
escaped = [(k.replace('%{', '%{escaped_'), base64Encode(v)) for (k, v) in config.substitutions]
config.substitutions.extend(escaped)
# The tests in this directory need to run Python
import pipes
import sys
config.substitutions.append(('%{python}', pipes.quote(sys.executable)))