[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/kexi-frameworks7-staniek] /: calligra_build_test -> calligra_add_test and modernize this m
From:       Jaroslaw Staniek <staniek () kde ! org>
Date:       2015-06-30 20:24:32
Message-ID: E1ZA252-0006Ps-1R () scm ! kde ! org
[Download RAW message or body]

Git commit 77a774490aaf8d58090834a633bbced7ab903a16 by Jaroslaw Staniek.
Committed on 30/06/2015 at 20:16.
Pushed by staniek into branch 'kexi-frameworks7-staniek'.

calligra_build_test -> calligra_add_test and modernize this macro

Now the usage is calligra_add_test(<app_prefix> <test_basename> <libraries_to_link>).

Prefixes help to select subsets of tests to run, e.g. only Krita tests or Flake \
tests.

M  +2    -1    CMakeLists.txt
A  +36   -0    cmake/modules/MacroCalligraAddTest.cmake
D  +0    -16   cmake/modules/MacroCalligraBuildTest.cmake

http://commits.kde.org/calligra/77a774490aaf8d58090834a633bbced7ab903a16

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0391869..6212625 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,7 @@ endif()
 # BUILD_TESTING and KDE4_BUILD_TESTS to be set to FALSE
 # better fixes welcome
 if (BUILD_TESTING)
+    add_definitions(-DBUILD_TESTING)
     set(KDE4_BUILD_TESTS TRUE)
 endif()
 
@@ -755,7 +756,7 @@ macro_log_feature(KProperty_FOUND "KProperty" "A property editing \
framework with  ###############################
 
 include(MacroCalligraAddBenchmark)
-include(MacroCalligraBuildTest)
+include(MacroCalligraAddTest)
 
  ####################
 #####################
diff --git a/cmake/modules/MacroCalligraAddTest.cmake \
b/cmake/modules/MacroCalligraAddTest.cmake new file mode 100644
index 0000000..f051589
--- /dev/null
+++ b/cmake/modules/MacroCalligraAddTest.cmake
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2012-2015 Jarosław Staniek <staniek@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+# Adds a single test with proper prefix.
+# Prefixes help to select subsets of tests to run, e.g. only Krita tests or Flake \
tests. +#
+# Usage: calligra_add_test(<prefix> <test_basename> <libraries_to_link>)
+#
+# Result: adds a test named "<prefix>-<test_basename>", with executable \
"<test_basename>" +#         and links it with libraries listed in \
<libraries_to_link>. +#
+# Example: calligra_add_test(kexi GlobalSearchTest keximain kexicore \
kexiextendedwidgets) +# -- adds a "kexi-GlobalSearchTest" test with executable \
GlobalSearchTest and links it with +#    libraries keximain, kexicore, \
kexiextendedwidgets. +#
+
+macro(CALLIGRA_ADD_TEST __test_prefix __test_basename)
+    set(_args "")
+    list(APPEND _libs ${ARGV})
+    list(REMOVE_AT _libs 0 1)
+
+    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
+    add_executable(${__test_basename} ${__test_basename}.cpp)
+    add_test(${__test_prefix}-${__test_basename} ${__test_basename})
+    ecm_mark_as_test(${__test_prefix}-${__test_basename})
+    target_link_libraries(${__test_basename} Qt5::Test ${_libs})
+    get_property(_COMPILE_FLAGS TARGET ${__test_basename} PROPERTY COMPILE_FLAGS)
+    set_property(TARGET ${__test_basename} PROPERTY COMPILE_FLAGS
+        ${_COMPILE_FLAGS}\ \
-DCURRENT_SOURCE_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}/\\""\ \
-DFILES_OUTPUT_DIR="\\"${CMAKE_CURRENT_BINARY_DIR}/\\"") +#if (BUILD_TEST_COVERAGE)
+#    target_link_libraries(${_test_name} gcov)
+#endif ()
+endmacro(CALLIGRA_ADD_TEST)
diff --git a/cmake/modules/MacroCalligraBuildTest.cmake \
b/cmake/modules/MacroCalligraBuildTest.cmake deleted file mode 100644
index e09c7af..0000000
--- a/cmake/modules/MacroCalligraBuildTest.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2012-2013 Jarosław Staniek <staniek@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-macro(CALLIGRA_BUILD_TEST __test_name)
-    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
-    set(_test_name Test${__test_name})
-    kde4_add_unit_test(${_test_name} TESTNAME ${_test_name} ${_test_name}.cpp)
-    target_link_libraries(${_test_name} ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS})
-    get_property(_COMPILE_FLAGS TARGET ${_test_name} PROPERTY COMPILE_FLAGS)
-    set_property(TARGET ${_test_name} PROPERTY COMPILE_FLAGS ${_COMPILE_FLAGS}\ \
                -DFILES_OUTPUT_DIR="\\"${CMAKE_CURRENT_BINARY_DIR}/\\"")
-#if (BUILD_TEST_COVERAGE)
-#    target_link_libraries(${_test_name} gcov)
-#endif ()
-endmacro(CALLIGRA_BUILD_TEST)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic