During test discovery, we invoke each test executable with --gtest_list_tests.
For this we use subprocess.Popen, which according to the Python docs only raises
exceptions when called with invalid arguments, or when the child process raises
an exception before the new program starts to execute. If the invocation returns
a non-zero code, we silently assume that it has succeeded and there are no tests
to be discovered there.
This happens when building with BUILD_SHARED_LIBS - due to a mishap in CMake, we
set the wrong rpath for tests that live 2 directories away from unittest/. When
invoking those executables with --gtest_list_tests, they fail to find their
libraries and error out. Lit just assumes everything went well and we end up
unknowingly running fewer tests in this configuration (~1700 instead of ~1800).
We can fix this by replacing the call to subprocess.Popen with
subprocess.check_output, so we get an exception when the child process returns
with a non-zero return code.