Allow test working directories with a relative path

toml-checker archive_d4f0cdf1
Duncan Ogilvie 4 years ago
parent 306bb3d4fc
commit d4f0cdf152

@ -5,6 +5,7 @@ if(CMKR_GENERATE_DOCUMENTATION)
# Hook the add_test function to capture the tests in the order declared in tests/cmake.toml # Hook the add_test function to capture the tests in the order declared in tests/cmake.toml
function(add_test) function(add_test)
cmake_parse_arguments(TEST "" "WORKING_DIRECTORY" "" ${ARGN}) cmake_parse_arguments(TEST "" "WORKING_DIRECTORY" "" ${ARGN})
get_filename_component(TEST_WORKING_DIRECTORY "${TEST_WORKING_DIRECTORY}" NAME)
list(APPEND CMKR_TESTS "${TEST_WORKING_DIRECTORY}") list(APPEND CMKR_TESTS "${TEST_WORKING_DIRECTORY}")
set(CMKR_TESTS "${CMKR_TESTS}" CACHE INTERNAL "") set(CMKR_TESTS "${CMKR_TESTS}" CACHE INTERNAL "")
_add_test(${test} ${ARGN}) _add_test(${test} ${ARGN})
@ -19,7 +20,9 @@ function(generate_documentation)
set(example_folder "${PROJECT_SOURCE_DIR}/docs/examples") set(example_folder "${PROJECT_SOURCE_DIR}/docs/examples")
file(GLOB example_files "${example_folder}/*.md") file(GLOB example_files "${example_folder}/*.md")
list(REMOVE_ITEM example_files "${example_folder}/index.md") list(REMOVE_ITEM example_files "${example_folder}/index.md")
if(example_files)
file(REMOVE ${example_files}) file(REMOVE ${example_files})
endif()
message(DEBUG "[cmkr] Test directories: ${CMKR_TESTS}") message(DEBUG "[cmkr] Test directories: ${CMKR_TESTS}")
set(test_index 0) set(test_index 0)

@ -721,7 +721,11 @@ int generate_cmake(const char *path, bool root) {
for (const auto &test : cmake.tests) { for (const auto &test : cmake.tests) {
auto name = std::make_pair("NAME", test.name); auto name = std::make_pair("NAME", test.name);
auto configurations = std::make_pair("CONFIGURATIONS", test.configurations); auto configurations = std::make_pair("CONFIGURATIONS", test.configurations);
auto working_directory = std::make_pair("WORKING_DIRECTORY", test.working_directory); auto dir = test.working_directory;
if (fs::is_directory(fs::path(path) / dir)) {
dir = "${CMAKE_CURRENT_LIST_DIR}/" + dir;
}
auto working_directory = std::make_pair("WORKING_DIRECTORY", dir);
auto command = std::make_pair("COMMAND", test.command); auto command = std::make_pair("COMMAND", test.command);
auto arguments = std::make_pair("", test.arguments); auto arguments = std::make_pair("", test.arguments);
cmd("add_test")(name, configurations, working_directory, command, arguments).endl(); cmd("add_test")(name, configurations, working_directory, command, arguments).endl();

@ -12,7 +12,7 @@ add_test(
NAME NAME
basic basic
WORKING_DIRECTORY WORKING_DIRECTORY
basic "${CMAKE_CURRENT_LIST_DIR}/basic"
COMMAND COMMAND
$<TARGET_FILE:cmkr> $<TARGET_FILE:cmkr>
build build
@ -22,7 +22,7 @@ add_test(
NAME NAME
interface interface
WORKING_DIRECTORY WORKING_DIRECTORY
interface "${CMAKE_CURRENT_LIST_DIR}/interface"
COMMAND COMMAND
$<TARGET_FILE:cmkr> $<TARGET_FILE:cmkr>
build build
@ -32,7 +32,7 @@ add_test(
NAME NAME
fetch-content fetch-content
WORKING_DIRECTORY WORKING_DIRECTORY
fetch-content "${CMAKE_CURRENT_LIST_DIR}/fetch-content"
COMMAND COMMAND
$<TARGET_FILE:cmkr> $<TARGET_FILE:cmkr>
build build
@ -42,7 +42,7 @@ add_test(
NAME NAME
conditions conditions
WORKING_DIRECTORY WORKING_DIRECTORY
conditions "${CMAKE_CURRENT_LIST_DIR}/conditions"
COMMAND COMMAND
$<TARGET_FILE:cmkr> $<TARGET_FILE:cmkr>
build build

Loading…
Cancel
Save