aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt9
-rw-r--r--cmake/Modules/WandaTargets.cmake30
-rw-r--r--tests/wanda/driver.cpp (renamed from tests/wanda/core_driver.cpp)13
-rw-r--r--tests/wanda/test_suite_xdg.cpp9
-rw-r--r--tests/wanda/test_suite_xdg.hpp16
5 files changed, 28 insertions, 49 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f9ce60..26e325a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,14 +95,7 @@ add_wanda_executable(NAME "wandac"
"CONAN_PKG::clara"
)
-add_wanda_test(NAME "wanda_core"
- SOURCES
- "core_driver.cpp"
- "test_suite_xdg.cpp"
-
- HEADERS
- "test_suite_xdg.hpp"
-
+add_wanda_test(NAME "xdg"
LIBRARIES
"wanda"
"LIB::CUTE"
diff --git a/cmake/Modules/WandaTargets.cmake b/cmake/Modules/WandaTargets.cmake
index 38fc169..4fc429c 100644
--- a/cmake/Modules/WandaTargets.cmake
+++ b/cmake/Modules/WandaTargets.cmake
@@ -92,44 +92,40 @@ endfunction()
function(add_wanda_test)
set(OPTIONS)
set(SV_ARGS "NAME")
- set(MV_ARGS "SOURCES;HEADERS;LIBRARIES")
+ set(MV_ARGS "HEADERS;LIBRARIES")
cmake_parse_arguments(WANDA_TEST "${OPTIONS}" "${SV_ARGS}" "${MV_ARGS}" ${ARGN})
if(NOT WANDA_TEST_NAME)
message(FATAL_ERROR "Missing argument 'NAME' to call of 'add_wanda_test'")
endif()
- if(NOT WANDA_TEST_SOURCES)
- message(FATAL_ERROR "Missing argument 'SOURCES' to call of 'add_wanda_test'")
+ if(NOT CUTE_FOUND)
+ message(STATUS "CUTE not found. Skipping test '${WANDA_TEST_NAME}'")
+ return()
endif()
- set(RESOLVED_SOURCES)
- foreach(SOURCE IN LISTS WANDA_TEST_SOURCES)
- list(APPEND RESOLVED_SOURCES "tests/wanda/${SOURCE}")
- endforeach()
-
set(RESOLVED_HEADERS)
foreach(HEADER IN LISTS WANDA_TEST_HEADERS)
- list(APPEND RESOLVED_HEADERS "tests/wanda/${HEADER}")
+ list(APPEND RESOLVED_HEADERS "include/wanda/${HEADER}")
endforeach()
- if(NOT CUTE_FOUND)
- message(STATUS "CUTE not found. Skipping test '${WANDA_TEST_NAME}'")
- return()
+ if(NOT TARGET "wanda_test_driver")
+ add_library("wanda_test_driver" OBJECT "tests/wanda/driver.cpp")
endif()
- add_executable("${WANDA_TEST_NAME}_driver"
- ${RESOLVED_SOURCES} # Source files
+ add_executable("test_${WANDA_TEST_NAME}"
+ "tests/wanda/test_suite_${WANDA_TEST_NAME}.cpp"
${RESOLVED_HEADERS} # Header files
+ $<TARGET_OBJECTS:wanda_test_driver>
)
- target_include_directories("${WANDA_TEST_NAME}_driver" SYSTEM PRIVATE
+ target_include_directories("test_${WANDA_TEST_NAME}" SYSTEM PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
- target_link_libraries("${WANDA_TEST_NAME}_driver"
+ target_link_libraries("test_${WANDA_TEST_NAME}"
${WANDA_TEST_LIBRARIES}
)
- add_test(NAME "${WANDA_TEST_NAME}" COMMAND "${WANDA_TEST_NAME}_driver")
+ add_test(NAME "${WANDA_TEST_NAME}" COMMAND "test_${WANDA_TEST_NAME}")
endfunction() \ No newline at end of file
diff --git a/tests/wanda/core_driver.cpp b/tests/wanda/driver.cpp
index 3643da0..e0dd7c8 100644
--- a/tests/wanda/core_driver.cpp
+++ b/tests/wanda/driver.cpp
@@ -1,5 +1,3 @@
-#include "test_suite_xdg.hpp"
-
#include "cute/cute.h"
#include "cute/cute_runner.h"
#include "cute/tap_listener.h"
@@ -7,12 +5,19 @@
#include <algorithm>
#include <iostream>
#include <iterator>
+#include <string>
+#include <utility>
#include <vector>
+namespace wanda::test
+{
+ std::pair<cute::suite, std::string> suite();
+}
+
int main(int argc, char const *const *argv)
{
auto listener = cute::tap_listener<>{std::cout};
auto runner = cute::makeRunner(listener, argc, argv);
- auto suites = std::vector<std::pair<cute::suite, std::string>>{wanda::test_suite_xdg()};
- return !all_of(cbegin(suites), cend(suites), [&](auto const &suite) { return runner(suite.first, suite.second.c_str()); });
+ auto suite = wanda::test::suite();
+ return !runner(suite.first, suite.second.c_str());
} \ No newline at end of file
diff --git a/tests/wanda/test_suite_xdg.cpp b/tests/wanda/test_suite_xdg.cpp
index 0338ee3..70597f7 100644
--- a/tests/wanda/test_suite_xdg.cpp
+++ b/tests/wanda/test_suite_xdg.cpp
@@ -1,13 +1,14 @@
-#include "test_suite_xdg.hpp"
#include <wanda/xdg.hpp>
-#include "cute/cute.h"
+#include <cute/cute.h>
#include <unistd.h>
#include <filesystem>
+#include <string>
+#include <utility>
-namespace wanda
+namespace wanda::test
{
namespace
@@ -76,7 +77,7 @@ void test_xdg_path_for_runtime_dir_with_xdg_runtime_dir_in_environment()
ASSERT_EQUAL("/home/cute/xdg_runtime_dir", xdg_path_for(xdg_directory::runtime_dir, env));
}
-std::pair<cute::suite, std::string> test_suite_xdg()
+std::pair<cute::suite, std::string> suite()
{
return std::make_pair(cute::suite{
CUTE(test_xdg_variables),
diff --git a/tests/wanda/test_suite_xdg.hpp b/tests/wanda/test_suite_xdg.hpp
deleted file mode 100644
index 698ad9a..0000000
--- a/tests/wanda/test_suite_xdg.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef WANDA_TEST_SUITE_XDG_HPP
-#define WANDA_TEST_SUITE_XDG_HPP
-
-#include "cute/cute.h"
-
-#include <string>
-#include <utility>
-
-namespace wanda
-{
-
-std::pair<cute::suite, std::string> test_suite_xdg();
-
-} // namespace wanda
-
-#endif \ No newline at end of file