lit: Execute RUN statement depending on features available


I know there is UNSUPPORTED keyword in lit that makes it ignore whole testcase based on presence of some feature. However, in my test I want to always RUN line A, but RUN line B only if “windows” feature is enabled.

Is it possible to do that?

// REQUIRES: system-windows


In some of my downstream work, I’ve configured lit substitutions that expand to the empty string or : depending on the presence of features, and I’ve put those at the start of the affected RUN commands. However, this doesn’t stop pipes or redirects, so I always use redirects to files that are fine to truncate when the RUN line is to be skipped.

I’m not aware of a cleaner solution, but it would be nice.