summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorJack Morrison <jackmorrison1@gmail.com>2014-04-16 17:15:59 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-16 18:01:52 (GMT)
commit1f3e95ba72cdafec0efb99d43a062b538780b093 (patch)
tree0da3d613af24defa56c8cfdc5151cc66aa685035 /Modules
parentfd8bb3427858017754d5b08a2eb1f57116feebb6 (diff)
downloadCMake-1f3e95ba72cdafec0efb99d43a062b538780b093.zip
CMake-1f3e95ba72cdafec0efb99d43a062b538780b093.tar.gz
CMake-1f3e95ba72cdafec0efb99d43a062b538780b093.tar.bz2
FindGTest: Teach GTEST_ADD_TESTS about TYPED_TEST
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindGTest.cmake24
1 files changed, 15 insertions, 9 deletions
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index c4f911d..6a36ea6 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -116,19 +116,25 @@ function(GTEST_ADD_TESTS executable extra_args)
get_property(ARGN TARGET ${executable} PROPERTY SOURCES)
endif()
set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*")
+ set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
foreach(source ${ARGN})
file(READ "${source}" contents)
- string(REGEX MATCHALL "TEST_?[FP]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+ string(REGEX MATCHALL "${gtest_test_type_regex}\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
foreach(hit ${found_tests})
- string(REGEX MATCH "TEST_?[FP]?" test_type ${hit})
+ string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
- # Parameterized tests have a different signature for the filter
- if(${test_type} STREQUAL "TEST_P")
- string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit})
- else()
- string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit})
- endif()
- add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
+ # Parameterized tests have a different signature for the filter
+ if(${test_type} STREQUAL "TEST_P")
+ string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit})
+ elseif(${test_type} STREQUAL "TEST_F" OR ${test_type} STREQUAL "TEST")
+ string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit})
+ elseif(${test_type} STREQUAL "TYPED_TEST")
+ string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit})
+ else()
+ message(WARNING "Could not parse GTest ${hit} for adding to CTest.")
+ continue()
+ endif()
+ add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
endforeach()
endforeach()
endfunction()