Files
CMake/Tests/RunCMake/GoogleTest/GoogleTest.cmake
Matthew Woehlke 70f9f62da8 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.
2017-11-21 12:05:34 -05:00

24 lines
399 B
CMake

project(test_include_dirs)
include(CTest)
include(GoogleTest)
enable_testing()
add_executable(fake_gtest fake_gtest.cpp)
gtest_discover_tests(
fake_gtest
TEST_PREFIX TEST:
TEST_SUFFIX !1
EXTRA_ARGS how now "\"brown\" cow"
PROPERTIES LABELS TEST1
)
gtest_discover_tests(
fake_gtest
TEST_PREFIX TEST:
TEST_SUFFIX !2
EXTRA_ARGS how now "\"brown\" cow"
PROPERTIES LABELS TEST2
)