mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
ctest: Add support for '--prefix=<prefix>' form of the argument
The main `cmake --preset` argument for configure presets supports both forms, so support it for `ctest --preset` too. Fixes: #21855
This commit is contained in:
@@ -30,7 +30,7 @@ This program will run the tests and report results.
|
||||
Options
|
||||
=======
|
||||
|
||||
``--preset <preset>``
|
||||
``--preset <preset>``, ``--preset=<preset>``
|
||||
Use a test preset to specify test options. The project binary directory
|
||||
is inferred from the ``configurePreset`` key. The current working directory
|
||||
must contain CMake preset files.
|
||||
|
@@ -2574,7 +2574,10 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
|
||||
|
||||
bool listPresets =
|
||||
find(args.begin(), args.end(), "--list-presets") != args.end();
|
||||
auto it = find(args.begin(), args.end(), "--preset");
|
||||
auto it =
|
||||
std::find_if(args.begin(), args.end(), [](std::string const& arg) -> bool {
|
||||
return arg == "--preset" || cmHasLiteralPrefix(arg, "--preset=");
|
||||
});
|
||||
if (listPresets || it != args.end()) {
|
||||
std::string errormsg;
|
||||
bool success;
|
||||
@@ -2583,7 +2586,10 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
|
||||
// If listing presets we don't need a presetName
|
||||
success = this->SetArgsFromPreset("", listPresets);
|
||||
} else {
|
||||
if (++it != args.end()) {
|
||||
if (cmHasLiteralPrefix(*it, "--preset=")) {
|
||||
auto presetName = it->substr(9);
|
||||
success = this->SetArgsFromPreset(presetName, listPresets);
|
||||
} else if (++it != args.end()) {
|
||||
auto presetName = *it;
|
||||
success = this->SetArgsFromPreset(presetName, listPresets);
|
||||
} else {
|
||||
|
@@ -26,7 +26,8 @@ static const char* cmDocumentationUsage[][2] = { { nullptr,
|
||||
{ nullptr, nullptr } };
|
||||
|
||||
static const char* cmDocumentationOptions[][2] = {
|
||||
{ "--preset <preset>", "Read arguments from a test preset." },
|
||||
{ "--preset <preset>, --preset=<preset>",
|
||||
"Read arguments from a test preset." },
|
||||
{ "--list-presets", "List available test presets." },
|
||||
{ "-C <cfg>, --build-config <cfg>", "Choose configuration to test." },
|
||||
{ "--progress", "Enable short progress output from tests." },
|
||||
|
@@ -51,6 +51,7 @@ function(run_cmake_test_presets name CMakePresetsTest_CONFIGURE_PRESETS CMakePre
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(eq 0)
|
||||
foreach(TEST_PRESET ${CMakePresetsTest_TEST_PRESETS})
|
||||
if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-test-${TEST_PRESET}-check.cmake")
|
||||
set(RunCMake-check-file "${name}-test-${TEST_PRESET}-check.cmake")
|
||||
@@ -58,8 +59,15 @@ function(run_cmake_test_presets name CMakePresetsTest_CONFIGURE_PRESETS CMakePre
|
||||
set(RunCMake-check-file "check.cmake")
|
||||
endif()
|
||||
|
||||
if(eq)
|
||||
run_cmake_command(${name}-test-${TEST_PRESET}
|
||||
${CMAKE_CTEST_COMMAND} "--preset=${TEST_PRESET}" ${ARGN})
|
||||
set(eq 0)
|
||||
else()
|
||||
run_cmake_command(${name}-test-${TEST_PRESET}
|
||||
${CMAKE_CTEST_COMMAND} "--preset" "${TEST_PRESET}" ${ARGN})
|
||||
set(eq 1)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
Reference in New Issue
Block a user