1919# If the specified target does not exist the registration is skipped.
2020#
2121# :param target: the target name which will also be used as the test name
22+ # if TEST_NAME is not set
2223# :type target: string
2324# :param RUNNER: the path to the test runner script (default: see ament_add_test).
2425# :type RUNNER: string
2829# :param WORKING_DIRECTORY: the working directory for invoking the
2930# executable in, default defined by ``ament_add_test()``
3031# :type WORKING_DIRECTORY: string
32+ # :param TEST_NAME: the name of the test
33+ # :type TEST_NAME: string
3134# :param SKIP_TEST: if set mark the test as being skipped
3235# :type SKIP_TEST: option
3336# :param ENV: list of env vars to set; listed as ``VAR=value``
@@ -48,16 +51,23 @@ function(ament_add_gtest_test target)
4851
4952 cmake_parse_arguments (ARG
5053 "SKIP_TEST"
51- "RUNNER;TIMEOUT;WORKING_DIRECTORY"
54+ "RUNNER;TIMEOUT;WORKING_DIRECTORY;TEST_NAME "
5255 "APPEND_ENV;APPEND_LIBRARY_DIRS;ENV"
5356 ${ARGN} )
5457 if (ARG_UNPARSED_ARGUMENTS)
5558 message (FATAL_ERROR
5659 "ament_add_gtest_test() called with unused arguments: ${ARGN} " )
5760 endif ()
5861
62+
63+ if (ARG_TEST_NAME)
64+ set (TEST_NAME "${ARG_TEST_NAME} " )
65+ else ()
66+ set (TEST_NAME "${target} " )
67+ endif ()
68+
5969 set (executable "$<TARGET_FILE:${target} >" )
60- set (result_file "${AMENT_TEST_RESULTS_DIR} /${PROJECT_NAME} /${target } .gtest.xml" )
70+ set (result_file "${AMENT_TEST_RESULTS_DIR} /${PROJECT_NAME} /${TEST_NAME } .gtest.xml" )
6171 set (cmd
6272 "${executable} "
6373 "--gtest_output=xml:${result_file} " )
@@ -84,9 +94,9 @@ function(ament_add_gtest_test target)
8494 endif ()
8595
8696 ament_add_test(
87- "${target } "
97+ "${TEST_NAME } "
8898 COMMAND ${cmd}
89- OUTPUT_FILE "${CMAKE_BINARY_DIR} /ament_cmake_gtest/${target } .txt"
99+ OUTPUT_FILE "${CMAKE_BINARY_DIR} /ament_cmake_gtest/${TEST_NAME } .txt"
90100 RESULT_FILE "${result_file} "
91101 ${ARG_RUNNER}
92102 ${ARG_SKIP_TEST}
@@ -97,7 +107,7 @@ function(ament_add_gtest_test target)
97107 ${ARG_WORKING_DIRECTORY}
98108 )
99109 set_tests_properties (
100- "${target } "
110+ "${TEST_NAME } "
101111 PROPERTIES
102112 REQUIRED_FILES "${executable} "
103113 LABELS "gtest"
0 commit comments