mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
Merge topic 'gtest-json-discovery-empty' into release-4.2
f67efb64ab GoogleTest: Restore support for empty discovered test list
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11326
This commit is contained in:
@@ -229,53 +229,51 @@ macro(parse_tests_from_json json_file)
|
||||
|
||||
# Return if there are no testsuites
|
||||
string(JSON len_test_suites LENGTH "${test_suites_json}")
|
||||
if(len_test_suites LESS_EQUAL 0)
|
||||
return()
|
||||
endif()
|
||||
if(len_test_suites GREATER 0)
|
||||
set(open_sb)
|
||||
set(close_sb)
|
||||
|
||||
set(open_sb)
|
||||
set(close_sb)
|
||||
math(EXPR upper_limit_test_suite_range "${len_test_suites} - 1")
|
||||
|
||||
math(EXPR upper_limit_test_suite_range "${len_test_suites} - 1")
|
||||
foreach(index_test_suite RANGE ${upper_limit_test_suite_range})
|
||||
string(JSON test_suite_json GET "${test_suites_json}" ${index_test_suite})
|
||||
|
||||
foreach(index_test_suite RANGE ${upper_limit_test_suite_range})
|
||||
string(JSON test_suite_json GET "${test_suites_json}" ${index_test_suite})
|
||||
# "suite" is expected to be set in write_test_to_file(). When parsing the
|
||||
# plain text output, "suite" is expected to be the original suite name
|
||||
# before accounting for pretty names. This may be used to construct the
|
||||
# name of XML output results files.
|
||||
string(JSON current_test_suite GET "${test_suite_json}" "name")
|
||||
string(JSON tests_json GET "${test_suite_json}" "testsuite")
|
||||
|
||||
# "suite" is expected to be set in write_test_to_file(). When parsing the
|
||||
# plain text output, "suite" is expected to be the original suite name
|
||||
# before accounting for pretty names. This may be used to construct the
|
||||
# name of XML output results files.
|
||||
string(JSON current_test_suite GET "${test_suite_json}" "name")
|
||||
string(JSON tests_json GET "${test_suite_json}" "testsuite")
|
||||
|
||||
# Skip test suites without tests
|
||||
string(JSON len_tests LENGTH "${tests_json}")
|
||||
if(len_tests LESS_EQUAL 0)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
math(EXPR upper_limit_test_range "${len_tests} - 1")
|
||||
foreach(index_test RANGE ${upper_limit_test_range})
|
||||
string(JSON test_json GET "${tests_json}" ${index_test})
|
||||
|
||||
string(JSON len_test_parameters LENGTH "${test_json}")
|
||||
if(len_test_parameters LESS_EQUAL 0)
|
||||
# Skip test suites without tests
|
||||
string(JSON len_tests LENGTH "${tests_json}")
|
||||
if(len_tests LESS_EQUAL 0)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
get_json_member_with_default(test_json "name" current_test_name)
|
||||
get_json_member_with_default(test_json "file" current_test_file)
|
||||
get_json_member_with_default(test_json "line" current_test_line)
|
||||
get_json_member_with_default(test_json "value_param" current_test_value_param)
|
||||
get_json_member_with_default(test_json "type_param" current_test_type_param)
|
||||
math(EXPR upper_limit_test_range "${len_tests} - 1")
|
||||
foreach(index_test RANGE ${upper_limit_test_range})
|
||||
string(JSON test_json GET "${tests_json}" ${index_test})
|
||||
|
||||
generate_testname_guards(
|
||||
"${current_test_suite}${current_test_name}${current_test_value_param}${current_test_type_param}"
|
||||
open_guard close_guard
|
||||
)
|
||||
write_test_to_file()
|
||||
string(JSON len_test_parameters LENGTH "${test_json}")
|
||||
if(len_test_parameters LESS_EQUAL 0)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
get_json_member_with_default(test_json "name" current_test_name)
|
||||
get_json_member_with_default(test_json "file" current_test_file)
|
||||
get_json_member_with_default(test_json "line" current_test_line)
|
||||
get_json_member_with_default(test_json "value_param" current_test_value_param)
|
||||
get_json_member_with_default(test_json "type_param" current_test_type_param)
|
||||
|
||||
generate_testname_guards(
|
||||
"${current_test_suite}${current_test_name}${current_test_value_param}${current_test_type_param}"
|
||||
open_guard close_guard
|
||||
)
|
||||
write_test_to_file()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(gtest_discover_tests_impl)
|
||||
|
||||
1
Tests/RunCMake/GoogleTest/GoogleTest-test8-stderr.txt
Normal file
1
Tests/RunCMake/GoogleTest/GoogleTest-test8-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
No tests were found!!!
|
||||
@@ -73,6 +73,15 @@ gtest_discover_tests(
|
||||
NO_PRETTY_TYPES
|
||||
)
|
||||
|
||||
gtest_discover_tests(
|
||||
fake_gtest
|
||||
TEST_PREFIX TEST:
|
||||
TEST_SUFFIX !8
|
||||
TEST_FILTER notests*
|
||||
EXTRA_ARGS how now "\"brown\" cow"
|
||||
PROPERTIES LABELS TEST8
|
||||
)
|
||||
|
||||
add_executable(no_tests_defined no_tests_defined.cpp)
|
||||
xcode_sign_adhoc(no_tests_defined)
|
||||
|
||||
|
||||
@@ -86,6 +86,13 @@ function(run_GoogleTest DISCOVERY_MODE)
|
||||
--no-label-summary
|
||||
)
|
||||
|
||||
run_cmake_command(GoogleTest-test8
|
||||
${CMAKE_CTEST_COMMAND}
|
||||
-C Debug
|
||||
-L TEST8
|
||||
--no-label-summary
|
||||
)
|
||||
|
||||
run_cmake_command(GoogleTest-test-missing
|
||||
${CMAKE_CTEST_COMMAND}
|
||||
-C Debug
|
||||
|
||||
Reference in New Issue
Block a user