changeset 395:f9b4101fa51c

Tests: do not copy resources anymore
author David Demelier <markand@malikania.fr>
date Tue, 10 Jan 2017 15:16:09 +0100
parents c6fbb6e0e06d
children 8681c6a9a9b2
files cmake/function/IrccdDefineTest.cmake tests/js-timer/CMakeLists.txt tests/js-timer/main.cpp
diffstat 3 files changed, 6 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/cmake/function/IrccdDefineTest.cmake	Sun Jan 01 15:29:41 2017 +0100
+++ b/cmake/function/IrccdDefineTest.cmake	Tue Jan 10 15:16:09 2017 +0100
@@ -24,7 +24,6 @@
 #    NAME the test name
 #    SOURCES the sources files
 #    LIBRARIES (Optional) libraries to link
-#    RESOURCES (Optional) some resources file to copy
 #    FLAGS (Optional) compilation flags
 # )
 #
@@ -35,7 +34,7 @@
 
 function(irccd_define_test)
     set(oneValueArgs NAME)
-    set(multiValueArgs SOURCES LIBRARIES RESOURCES FLAGS)
+    set(multiValueArgs SOURCES LIBRARIES FLAGS)
 
     cmake_parse_arguments(TEST "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
@@ -46,25 +45,12 @@
         message(FATAL_ERROR "Please set SOURCES")
     endif ()
 
-    foreach (r ${TEST_RESOURCES})
-        file(RELATIVE_PATH output ${CMAKE_CURRENT_SOURCE_DIR} ${r})
-
-        add_custom_command(
-            OUTPUT ${CMAKE_BINARY_DIR}/tests/${output}
-            COMMAND ${CMAKE_COMMAND} -E copy ${r} ${CMAKE_BINARY_DIR}/tests/${output}
-            DEPENDS ${r}
-        )
-
-        list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/tests/${output})
-    endforeach ()
-
     # Always link to googletest
     list(APPEND TEST_LIBRARIES libirccd-test)
 
     # Executable
-    add_executable(test-${TEST_NAME} ${TEST_SOURCES} ${TEST_RESOURCES} ${RESOURCES})
+    add_executable(test-${TEST_NAME} ${TEST_SOURCES})
     target_link_libraries(test-${TEST_NAME} ${TEST_LIBRARIES})
-    source_group(Auto-generated FILES ${RESOURCES})
 
     target_include_directories(
         test-${TEST_NAME}
--- a/tests/js-timer/CMakeLists.txt	Sun Jan 01 15:29:41 2017 +0100
+++ b/tests/js-timer/CMakeLists.txt	Tue Jan 10 15:16:09 2017 +0100
@@ -19,9 +19,6 @@
 irccd_define_test(
     NAME js-timer
     SOURCES main.cpp
-    RESOURCES
-        ${CMAKE_CURRENT_SOURCE_DIR}/timer-single.js
-        ${CMAKE_CURRENT_SOURCE_DIR}/timer-repeat.js
-        ${CMAKE_CURRENT_SOURCE_DIR}/timer-pending.js
     LIBRARIES libirccd-js
+    FLAGS DIRECTORY=\"${CMAKE_CURRENT_SOURCE_DIR}\"
 )
--- a/tests/js-timer/main.cpp	Sun Jan 01 15:29:41 2017 +0100
+++ b/tests/js-timer/main.cpp	Tue Jan 10 15:16:09 2017 +0100
@@ -50,7 +50,7 @@
 
 TEST_F(TestJsTimer, single)
 {
-    open(IRCCD_TESTS_DIRECTORY "/timer-single.js");
+    open(DIRECTORY "/timer-single.js");
 
     ElapsedTimer timer;
 
@@ -63,7 +63,7 @@
 
 TEST_F(TestJsTimer, repeat)
 {
-    open(IRCCD_TESTS_DIRECTORY "/timer-repeat.js");
+    open(DIRECTORY "/timer-repeat.js");
 
     ElapsedTimer timer;
 
@@ -88,7 +88,7 @@
     Irccd irccd;
     ElapsedTimer timer;
 
-    auto plugin = std::make_shared<Plugin>("timer", IRCCD_TESTS_DIRECTORY "/timer-pending.js");
+    auto plugin = std::make_shared<Plugin>("timer", DIRECTORY "/timer-pending.js");
 
     irccd.addPlugin(plugin);
     irccd.poll();