Files
CMake/Tests/RunCMake/GoogleTest/Launcher.cmake
Craig Scott fc7aa3cd69 tests: Preserve empty arguments in test command lines
This will now preserve empty values in the TEST_LAUNCHER and
CROSSCOMPILING_EMULATOR target properties for tests added by:

- The add_test() command.
- The ExternalData_Add_Test() command from the ExternalData module.
- The gtest_add_tests() or gtest_discover_tests() commands from the
  GoogleTest module.

For the gtest_add_tests() and gtest_discover_tests() commands,
empty elements in the values passed after the EXTRA_ARGS keyword
are also now preserved.

Policy CMP0178 is added to provide backward compatibility with the
old behavior where empty values were silently discarded from the
above cases.

Fixes: #26337
2024-10-02 10:09:11 +10:00

36 lines
754 B
CMake

enable_language(C)
include(GoogleTest)
enable_testing()
include(xcode_sign_adhoc.cmake)
add_executable(test_launcher test_launcher.c)
add_executable(launcher_test launcher_test.c)
xcode_sign_adhoc(launcher_test)
set(launcher
"$<TARGET_FILE:test_launcher>"
"" # Verify CMP0178's handling of an empty list item
"launcherparam"
"--"
)
set_property(TARGET launcher_test PROPERTY TEST_LAUNCHER "${launcher}")
set(emulator
"$<TARGET_FILE:test_launcher>"
"" # Verify CMP0178's handling of an empty list item
"emulatorparam"
"--"
)
set_property(TARGET launcher_test PROPERTY CROSSCOMPILING_EMULATOR "${emulator}")
gtest_discover_tests(
launcher_test
EXTRA_ARGS a "" b
)
gtest_add_tests(
TARGET launcher_test
EXTRA_ARGS a "" b
)