Currently, lit tests don't set neither the module cache for building inferiors nor the module cache used by lldb when running tests. Furthermore, we have several places where we rely on the path to the module cache being always the same, rather than passing the correct value around. This makes it hard to specify a different module cache path when debugging a a test.
This patch reworks how we determine and pass around the module cache paths and fixes the omission on the lit side. It also adds a sanity check to the lit and dotest suites.
It seems weird to expose these as user-settable cmake variables, but then have a test which will fail if the user changes them in any way. Were you intending to have this feature be configurable at the cmake level? If not, could you change the cmake cache variables into something else (looks like regular variables should work just fine). If yes, then we should have a different testing strategy..