No behavior is changed if LLVM_TARGET_TRIPLE_ENV is blank or undefined.
If LLVM_TARGET_TRIPLE_ENV is "TEST_TARGET_TRIPLE" and $TEST_TARGET_TRIPLE is not blank,
llvm::sys::getDefaultTargetTriple() returns $TEST_TARGET_TRIPLE.
Lit resets config.target_triple and config.environment[LLVM_TARGET_TRIPLE_ENV] to change the default target.
Without changing LLVM_DEFAULT_TARGET_TRIPLE nor rebuilding, lit can be run;
TEST_TARGET_TRIPLE=i686-pc-win32 bin/llvm-lit -sv path/to/test/ TEST_TARGET_TRIPLE=i686-pc-win32 ninja check-clang-tools
Why I make the name of an environment variable configurable? Because...
- Let this functionality configurable.
- I'd not like to hear "Why $CLANG_TARGET is unavailable in spite of $LLVM_TARGET there"
In the future, I am planning to implement running triple matrix in Lit.
For example, running each test for each triple {i686|x86_64}-{mingw32|win32}.
Then, some commands, like FileCheck and commands with an explicit triple, aren't required to run iteratively.