mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 07:11:52 +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
|
Options
|
||||||
=======
|
=======
|
||||||
|
|
||||||
``--preset <preset>``
|
``--preset <preset>``, ``--preset=<preset>``
|
||||||
Use a test preset to specify test options. The project binary directory
|
Use a test preset to specify test options. The project binary directory
|
||||||
is inferred from the ``configurePreset`` key. The current working directory
|
is inferred from the ``configurePreset`` key. The current working directory
|
||||||
must contain CMake preset files.
|
must contain CMake preset files.
|
||||||
|
@@ -2574,7 +2574,10 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
|
|||||||
|
|
||||||
bool listPresets =
|
bool listPresets =
|
||||||
find(args.begin(), args.end(), "--list-presets") != args.end();
|
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()) {
|
if (listPresets || it != args.end()) {
|
||||||
std::string errormsg;
|
std::string errormsg;
|
||||||
bool success;
|
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
|
// If listing presets we don't need a presetName
|
||||||
success = this->SetArgsFromPreset("", listPresets);
|
success = this->SetArgsFromPreset("", listPresets);
|
||||||
} else {
|
} 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;
|
auto presetName = *it;
|
||||||
success = this->SetArgsFromPreset(presetName, listPresets);
|
success = this->SetArgsFromPreset(presetName, listPresets);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -26,7 +26,8 @@ static const char* cmDocumentationUsage[][2] = { { nullptr,
|
|||||||
{ nullptr, nullptr } };
|
{ nullptr, nullptr } };
|
||||||
|
|
||||||
static const char* cmDocumentationOptions[][2] = {
|
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." },
|
{ "--list-presets", "List available test presets." },
|
||||||
{ "-C <cfg>, --build-config <cfg>", "Choose configuration to test." },
|
{ "-C <cfg>, --build-config <cfg>", "Choose configuration to test." },
|
||||||
{ "--progress", "Enable short progress output from tests." },
|
{ "--progress", "Enable short progress output from tests." },
|
||||||
|
@@ -51,6 +51,7 @@ function(run_cmake_test_presets name CMakePresetsTest_CONFIGURE_PRESETS CMakePre
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(eq 0)
|
||||||
foreach(TEST_PRESET ${CMakePresetsTest_TEST_PRESETS})
|
foreach(TEST_PRESET ${CMakePresetsTest_TEST_PRESETS})
|
||||||
if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-test-${TEST_PRESET}-check.cmake")
|
if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-test-${TEST_PRESET}-check.cmake")
|
||||||
set(RunCMake-check-file "${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")
|
set(RunCMake-check-file "check.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
run_cmake_command(${name}-test-${TEST_PRESET}
|
if(eq)
|
||||||
${CMAKE_CTEST_COMMAND} "--preset" "${TEST_PRESET}" ${ARGN})
|
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()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user