Skip to content

GoogleTest: Fix multiple discovery on same target

According to the documentation, tests can be discovered for a target multiple times by using a different prefix and/or suffix to ensure name uniqueness. However, while this worked for gtest_add_tests, it did not work with gtest_discover_tests because the generated file that sets up the tests was named based only on the target name, and so subsequent discovery from the same target would clobber earlier discovery.

Fix this by introducing a counter that records how many times discovery has been used on a target, and use this to generate unique names of the generated test list files.

Merge request reports