瀏覽代碼

Merge topic 'gtest_add_tests-empty-file'

31c82143bf GoogleTest: gtest_add_tests() fails if any source file is empty
d6b06d8d87 GoogleTest: Modify test to verify that empty files can be scanned

Acked-by: Kitware Robot <[email protected]>
Merge-request: !2342
Craig Scott 7 年之前
父節點
當前提交
344eb9c8dc
共有 3 個文件被更改,包括 5 次插入4 次删除
  1. 1 1
      Modules/GoogleTest.cmake
  2. 4 3
      Tests/GoogleTest/Test/CMakeLists.txt
  3. 0 0
      Tests/GoogleTest/Test/empty.cxx

+ 1 - 1
Modules/GoogleTest.cmake

@@ -308,7 +308,7 @@ function(gtest_add_tests)
       set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
     endif()
     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})
       string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
 

+ 4 - 3
Tests/GoogleTest/Test/CMakeLists.txt

@@ -44,12 +44,13 @@ endif()
 set_tests_properties(set2.GoogleTest.ConditionalFail.foo PROPERTIES WILL_FAIL YES)
 
 
-# Search specific sources to get the test list
-add_executable(test_gtest2 main2.cxx)
+# Search specific sources to get the test list. Include an empty file
+# to ensure they are handled correctly too.
+add_executable(test_gtest2 main2.cxx empty.cxx)
 target_link_libraries(test_gtest2 GTest::Main)
 gtest_add_tests(TARGET test_gtest2
   TEST_LIST testList
-  SOURCES main2.h
+  SOURCES main2.h empty.cxx
 )
 set(expectedTests
   GoogleTest.SomethingElse

+ 0 - 0
Tests/GoogleTest/Test/empty.cxx