The lit test formats use largely the same logic for discovering tests. There are
some superficial differences in the logic, which seem reasonable enough to
handle in a single routine.
At a high level, the common goal is "look for files that end with one of these
suffixes, and skip anything starting with a dot." The balance of the logic
specific to ShTest and GoogleTest collapses quite a bit, so that
getTestsInDirectory is only a couple of lines around a call to the new function.
Note that this is a subtle change in behavior from os.path.splitext(). Consider a file without an extension, such as TARGETS:
The previous logic, which used os.path.splitext(), would not include the file, even if 'TARGETS' were included as a suffix. This new logic would include it, since TARGETS.endswith('TARGETS') returns True.
I'm not sure if any consumers of lit rely on this behavior... but if you didn't intend to make a change, perhaps keep the old behavior for now?