Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/Modules/GTestAddTests.cmake
| Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | function(gtest_discover_tests_impl) | ||||
| string(REPLACE "\n" ";" output "${output}") | string(REPLACE "\n" ";" output "${output}") | ||||
| # Parse output | # Parse output | ||||
| foreach(line ${output}) | foreach(line ${output}) | ||||
| # Skip header | # Skip header | ||||
| if(NOT line MATCHES "gtest_main\\.cc") | if(NOT line MATCHES "gtest_main\\.cc") | ||||
| # Do we have a module name or a test name? | # Do we have a module name or a test name? | ||||
| if(NOT line MATCHES "^ ") | if(NOT line MATCHES "^ ") | ||||
| # BLENDER: create a test command that runs an entire test suite, rather | |||||
| # than a command for every individual test case. | |||||
| # Module; remove trailing '.' to get just the name... | # Module; remove trailing '.' to get just the name... | ||||
| string(REGEX REPLACE "\\.( *#.*)?" "" suite "${line}") | string(REGEX REPLACE "\\.( *#.*)?" "" suite "${line}") | ||||
| if(line MATCHES "#" AND NOT _NO_PRETTY_TYPES) | if(line MATCHES "#" AND NOT _NO_PRETTY_TYPES) | ||||
| string(REGEX REPLACE "/[0-9]\\.+ +#.*= +" "/" pretty_suite "${line}") | string(REGEX REPLACE "/[0-9]\\.+ +#.*= +" "/" pretty_suite "${line}") | ||||
| else() | else() | ||||
| set(pretty_suite "${suite}") | set(pretty_suite "${suite}") | ||||
| endif() | endif() | ||||
| string(REGEX REPLACE "^DISABLED_" "" pretty_suite "${pretty_suite}") | string(REGEX REPLACE "^DISABLED_" "" pretty_suite "${pretty_suite}") | ||||
| else() | |||||
| # Test name; strip spaces and comments to get just the name... | |||||
| string(REGEX REPLACE " +" "" test "${line}") | |||||
| if(test MATCHES "#" AND NOT _NO_PRETTY_VALUES) | |||||
| string(REGEX REPLACE "/[0-9]+#GetParam..=" "/" pretty_test "${test}") | |||||
| else() | |||||
| string(REGEX REPLACE "#.*" "" pretty_test "${test}") | |||||
| endif() | |||||
| string(REGEX REPLACE "^DISABLED_" "" pretty_test "${pretty_test}") | |||||
| string(REGEX REPLACE "#.*" "" test "${test}") | |||||
| if(NOT "${_TEST_XML_OUTPUT_DIR}" STREQUAL "") | if(NOT "${_TEST_XML_OUTPUT_DIR}" STREQUAL "") | ||||
| set(TEST_XML_OUTPUT_PARAM "--gtest_output=xml:${_TEST_XML_OUTPUT_DIR}/${prefix}${suite}.${test}${suffix}.xml") | set(TEST_XML_OUTPUT_PARAM "--gtest_output=xml:${_TEST_XML_OUTPUT_DIR}/${prefix}${suite}.${test}${suffix}.xml") | ||||
| else() | else() | ||||
| unset(TEST_XML_OUTPUT_PARAM) | unset(TEST_XML_OUTPUT_PARAM) | ||||
| endif() | endif() | ||||
| # sanitize test name for further processing downstream | # sanitize test name for further processing downstream | ||||
| set(testname "${prefix}${pretty_suite}.${pretty_test}${suffix}") | set(suitename "${prefix}${pretty_suite}") | ||||
| # escape \ | # escape \ | ||||
| string(REPLACE [[\]] [[\\]] testname "${testname}") | string(REPLACE [[\]] [[\\]] suitename "${suitename}") | ||||
| # escape ; | # escape ; | ||||
| string(REPLACE [[;]] [[\;]] testname "${testname}") | string(REPLACE [[;]] [[\;]] suitename "${suitename}") | ||||
| # escape $ | # escape $ | ||||
| string(REPLACE [[$]] [[\$]] testname "${testname}") | string(REPLACE [[$]] [[\$]] suitename "${suitename}") | ||||
| # ...and add to script | # ...and add to script | ||||
| add_command(add_test | add_command(add_test | ||||
| "${testname}" | "${suitename}" | ||||
| ${_TEST_EXECUTOR} | ${_TEST_EXECUTOR} | ||||
| "${_TEST_EXECUTABLE}" | "${_TEST_EXECUTABLE}" | ||||
| "--gtest_filter=${suite}.${test}" | "--gtest_filter=${suite}.*" | ||||
| "--gtest_also_run_disabled_tests" | "--gtest_also_run_disabled_tests" | ||||
| ${TEST_XML_OUTPUT_PARAM} | ${TEST_XML_OUTPUT_PARAM} | ||||
| ${extra_args} | ${extra_args} | ||||
| ) | ) | ||||
| if(suite MATCHES "^DISABLED" OR test MATCHES "^DISABLED") | if(suite MATCHES "^DISABLED") | ||||
| add_command(set_tests_properties | add_command(set_tests_properties | ||||
| "${testname}" | "${suitename}" | ||||
| PROPERTIES DISABLED TRUE | PROPERTIES DISABLED TRUE | ||||
| ) | ) | ||||
| endif() | endif() | ||||
| add_command(set_tests_properties | add_command(set_tests_properties | ||||
| "${testname}" | "${suitename}" | ||||
| PROPERTIES | PROPERTIES | ||||
| WORKING_DIRECTORY "${_TEST_WORKING_DIR}" | WORKING_DIRECTORY "${_TEST_WORKING_DIR}" | ||||
| SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]" | SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]" | ||||
| ${properties} | ${properties} | ||||
| ) | ) | ||||
| list(APPEND tests_buffer "${testname}") | list(APPEND tests_buffer "${suitename}") | ||||
| list(LENGTH tests_buffer tests_buffer_length) | list(LENGTH tests_buffer tests_buffer_length) | ||||
| if(${tests_buffer_length} GREATER "250") | if(${tests_buffer_length} GREATER "250") | ||||
| flush_tests_buffer() | flush_tests_buffer() | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| endforeach() | endforeach() | ||||
| Show All 28 Lines | |||||