Do somebody know how to parametrize a llvm-lit script? I need to pass some environment variable value into a script to use it inside command line of some tool.
For example, test script could have the following line:
// RUN: some-tool $SOME_ENV_VAR
I need to pass SOME_ENV_VAR value somehow.
According to the documentation for llvm-lit there is an option -D or --param, but is is unclear how to access this user defined parameter inside a script.
Thank you in advance.
If you're able to modify the lit.cfg script (or the script used to generate the config), you can use all the flexibility of Python in there. For example, you can add:
some_var = os.environ.get('SOME_ENV_VAR', '')
Then you can add find-replace tuples:
config.substitutions.append(('%some_var', some_var))
Now whenever you have %some_var appear in a RUN line, lit will substitute the value of the environment variable as it was when your test suite began.