Merge topic 'add_test-empty-args'

1df3287bf6 add_test: Restore support for empty test arguments

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8551
This commit is contained in:
Brad King
2023-06-12 10:41:26 +00:00
committed by Kitware Robot
4 changed files with 26 additions and 1 deletions

View File

@@ -152,7 +152,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
this->EvaluateCommandLineArguments(this->Test->GetCommand(), ge, config),
// Expand arguments if COMMAND_EXPAND_LISTS is set
this->Test->GetCommandExpandLists() ? cmList::ExpandElements::Yes
: cmList::ExpandElements::No
: cmList::ExpandElements::No,
cmList::EmptyElements::Yes
};
// Expanding lists on an empty command may have left it empty
if (argv.empty()) {

View File

@@ -0,0 +1,11 @@
if (NOT CMAKE_ARGV4 STREQUAL "A")
message(FATAL_ERROR "wrong parsing of arguments")
endif()
if (NOT CMAKE_ARGV5 STREQUAL "")
message(FATAL_ERROR "Empty argument was dropped")
endif()
if (NOT CMAKE_ARGV6 STREQUAL "B")
message(FATAL_ERROR "wrong parsing of arguments")
endif()

View File

@@ -0,0 +1,5 @@
enable_testing()
add_test(
NAME "EmptyArgument"
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/CheckEmptyArgument.cmake" -- "A" "" "B"
)

View File

@@ -33,3 +33,11 @@ foreach(case IN LISTS cases)
run_case(OLD-${case})
run_case(NEW-${case})
endforeach()
block()
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/EmptyArgument-build)
run_cmake(EmptyArgument)
# Run ctest on the generated CTestTestfile.cmake.
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(EmptyArgument-ctest ${CMAKE_CTEST_COMMAND} -C Debug)
endblock()