Commit 344eb9c8 authored by Craig Scott's avatar Craig Scott Committed by Kitware Robot
Browse files

Merge topic 'gtest_add_tests-empty-file'

31c82143 GoogleTest: gtest_add_tests() fails if any source file is empty
d6b06d8d

 GoogleTest: Modify test to verify that empty files can be scanned
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2342
parents 528d7625 31c82143
...@@ -308,7 +308,7 @@ function(gtest_add_tests) ...@@ -308,7 +308,7 @@ function(gtest_add_tests)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source}) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
endif() endif()
file(READ "${source}" contents) file(READ "${source}" contents)
string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([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}) foreach(hit ${found_tests})
string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit}) string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
......
...@@ -44,12 +44,13 @@ endif() ...@@ -44,12 +44,13 @@ endif()
set_tests_properties(set2.GoogleTest.ConditionalFail.foo PROPERTIES WILL_FAIL YES) set_tests_properties(set2.GoogleTest.ConditionalFail.foo PROPERTIES WILL_FAIL YES)
# Search specific sources to get the test list # Search specific sources to get the test list. Include an empty file
add_executable(test_gtest2 main2.cxx) # to ensure they are handled correctly too.
add_executable(test_gtest2 main2.cxx empty.cxx)
target_link_libraries(test_gtest2 GTest::Main) target_link_libraries(test_gtest2 GTest::Main)
gtest_add_tests(TARGET test_gtest2 gtest_add_tests(TARGET test_gtest2
TEST_LIST testList TEST_LIST testList
SOURCES main2.h SOURCES main2.h empty.cxx
) )
set(expectedTests set(expectedTests
GoogleTest.SomethingElse GoogleTest.SomethingElse
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment