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
function(add_test)
cmake_parse_arguments(TEST "" "WORKING_DIRECTORY" "" ${ARGN})
get_filename_component(TEST_WORKING_DIRECTORY "${TEST_WORKING_DIRECTORY}" NAME)
list(APPEND CMKR_TESTS "${TEST_WORKING_DIRECTORY}")
set(CMKR_TESTS "${CMKR_TESTS}" CACHE INTERNAL "")
_add_test(${test} ${ARGN})
@ -19,7 +20,9 @@ function(generate_documentation)
set(example_folder "${PROJECT_SOURCE_DIR}/docs/examples")
file(GLOB example_files "${example_folder}/*.md")
list(REMOVE_ITEM example_files "${example_folder}/index.md")
file(REMOVE ${example_files})
if(example_files)
file(REMOVE ${example_files})
endif()
message(DEBUG "[cmkr] Test directories: ${CMKR_TESTS}")
set(test_index 0)

@ -721,7 +721,11 @@ int generate_cmake(const char *path, bool root) {
for (const auto &test : cmake.tests) {
auto name = std::make_pair("NAME", test.name);
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 arguments = std::make_pair("", test.arguments);
cmd("add_test")(name, configurations, working_directory, command, arguments).endl();

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

Loading…
Cancel
Save