Skip to content

Commit

Permalink
Refs #11903. Change TEST to TYPED_TEST
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Jul 5, 2021
1 parent 02ded61 commit ea4c8b4
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 123 deletions.
31 changes: 31 additions & 0 deletions cmake/common/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ macro(add_gtest)
endif()

foreach(GTEST_SOURCE_FILE ${GTEST_SOURCES})
# Normal tests
file(STRINGS ${GTEST_SOURCE_FILE} GTEST_TEST_NAMES REGEX ^TEST)
foreach(GTEST_TEST_NAME ${GTEST_TEST_NAMES})
string(REGEX REPLACE ["\) \(,"] ";" GTEST_TEST_NAME ${GTEST_TEST_NAME})
Expand Down Expand Up @@ -144,6 +145,36 @@ macro(add_gtest)
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} PROPERTY LABELS "${GTEST_LABELS}")

endforeach()

# Typed tests
file(STRINGS ${GTEST_SOURCE_FILE} GTEST_TEST_NAMES REGEX ^TYPED_TEST)
foreach(GTEST_TEST_NAME ${GTEST_TEST_NAMES})
string(REGEX REPLACE ["\) \(,"] ";" GTEST_TEST_NAME ${GTEST_TEST_NAME})
list(GET GTEST_TEST_NAME 1 GTEST_GROUP_NAME)
list(GET GTEST_TEST_NAME 3 GTEST_TEST_NAME)
add_test(NAME ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME}
COMMAND ${command} --gtest_filter=${GTEST_GROUP_NAME}*/*.${GTEST_TEST_NAME})

# Add environment
set(GTEST_ENVIRONMENT "")
if(WIN32)
set(GTEST_ENVIRONMENT "PATH=${WIN_PATH}")
endif()

foreach(property ${GTEST_ENVIRONMENTS})
list(APPEND GTEST_ENVIRONMENT "${property}")
endforeach()

if(GTEST_ENVIRONMENT)
set_tests_properties(${GTEST_GROUP_NAME}.${GTEST_TEST_NAME}
PROPERTIES ENVIRONMENT "${GTEST_ENVIRONMENT}")
endif()
unset(GTEST_ENVIRONMENT)

# Add labels
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} PROPERTY LABELS "${GTEST_LABELS}")

endforeach()
endforeach()
else()
add_test(NAME ${test} COMMAND ${command})
Expand Down
Loading

0 comments on commit ea4c8b4

Please sign in to comment.