aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorl10n daemon script <scripty@kde.org>2015-11-08 21:01:33 +0000
committerl10n daemon script <scripty@kde.org>2015-11-08 21:01:33 +0000
commit7feccae76e01a65b406995b5ba9526fe9ade4299 (patch)
tree99011137f4dedcf4bf242e167ac7dc70d9136b8e /tests
parenta1bb0b0488843165e606771b75a3a67ba8a131a6 (diff)
parentc88bc78e0ca3834c46b89ca9d14b404751da5d4a (diff)
downloadextra-cmake-modules-5.16.0-rc2.tar.gz
extra-cmake-modules-5.16.0-rc2.tar.bz2
Merge remote-tracking branch 'origin/master' into local_releasev5.16.0-rc2v5.16.0
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt8
-rw-r--r--tests/ECMAddTests/CMakeLists.txt49
-rw-r--r--tests/ECMAddTests/check_files.cmake15
-rw-r--r--tests/ECMAddTests/multi_tests/CMakeLists.txt155
-rw-r--r--tests/ECMAddTests/multi_tests/test1.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test2.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test3.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test4.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test5.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test6.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test7.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test8.cpp8
-rw-r--r--tests/ECMAddTests/multi_tests/test9.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/CMakeLists.txt122
-rw-r--r--tests/ECMAddTests/single_tests/test1.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/test2.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/test3.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/test4.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/test5.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/test6.cpp8
-rw-r--r--tests/ECMAddTests/single_tests/test6body.cpp7
-rw-r--r--tests/ECMAddTests/testhelper.cpp8
-rw-r--r--tests/ECMAddTests/testhelper.h1
-rw-r--r--tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h0
-rw-r--r--tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h0
-rw-r--r--tests/ECMGenerateHeadersTest/CommonHeader4
-rw-r--r--tests/ECMGenerateHeadersTest/headtest4.h0
-rw-r--r--tests/ECMGenerateHeadersTest/run_test.cmake.config110
-rw-r--r--tests/ECMGeneratePkgConfigFile/CMakeLists.txt2
-rw-r--r--tests/ECMInstallIconsTest/CMakeLists.txt23
-rw-r--r--tests/ECMInstallIconsTest/check_tree.cmake.in7
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png (renamed from tests/ECMInstallIconsTest/16-apps-cmake.png)bin233 -> 233 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cachebin0 -> 124 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cachebin0 -> 548 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cachebin0 -> 472 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cachebin0 -> 120 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cachebin0 -> 548 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cachebin0 -> 472 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cachebin0 -> 164 bytes
-rw-r--r--tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cachebin0 -> 452 bytes
-rw-r--r--tests/ECMInstallIconsTest/hi16-actions-old-style-name.pngbin0 -> 233 bytes
-rw-r--r--tests/ECMInstallIconsTest/subdir/16-apps-cmake.pngbin0 -> 233 bytes
-rw-r--r--tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt1
-rw-r--r--tests/ECMPoQmToolsTest/CMakeLists.txt57
-rw-r--r--tests/ECMPoQmToolsTest/check.cmake.in (renamed from tests/ECMPoQmToolsTest/check_tree.cmake.in)40
-rw-r--r--tests/ECMPoQmToolsTest/check_conf.cmake.in2
-rw-r--r--tests/ECMPoQmToolsTest/subdir/CMakeLists.txt5
-rw-r--r--tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po22
-rw-r--r--tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po22
-rw-r--r--tests/ECMPoQmToolsTest/tr_test.cpp43
-rw-r--r--tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt42
-rw-r--r--tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp108
-rw-r--r--tests/ExecuteKDEModules/CMakeLists.txt5
-rw-r--r--tests/test_helpers.cmake28
54 files changed, 980 insertions, 26 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index bc3e5ce8..9e6de12f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -4,6 +4,7 @@
# with other files (as ECM itself is architecture-independent).
project(ECMTests C)
+add_subdirectory(ECMAddTests)
add_subdirectory(ECMGenerateHeadersTest)
add_subdirectory(ECMSetupVersionTest)
add_subdirectory(ECMGeneratePkgConfigFile)
@@ -84,6 +85,9 @@ if (TARGET Qt5::qmake)
add_test_variant(KDEInstallDirsTest.relative_or_absolute_qt
KDEInstallDirsTest.relative_or_absolute dummy)
endif ()
+if (Qt5Core_FOUND)
+ add_test_macro(ECMQtDeclareLoggingCategoryTest testmain)
+endif()
add_test_macro(FindModules dummy)
add_test_macro(UseFindModules dummy)
@@ -97,13 +101,13 @@ add_test_macro(ECMInstallIconsTest
${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/check_tree.cmake"
)
-if (Qt5LinguistTools_FOUND)
+if (Qt5Core_FOUND AND Qt5LinguistTools_FOUND)
set(ECMPoQmToolsTest_EXTRA_OPTIONS
--build-target install
--build-options
"-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/InstallDirectory"
)
add_test_macro(ECMPoQmToolsTest
- ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check_tree.cmake"
+ ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check.cmake"
)
endif()
diff --git a/tests/ECMAddTests/CMakeLists.txt b/tests/ECMAddTests/CMakeLists.txt
new file mode 100644
index 00000000..e77b33f9
--- /dev/null
+++ b/tests/ECMAddTests/CMakeLists.txt
@@ -0,0 +1,49 @@
+macro(add_check NAME)
+ string(REPLACE "." "/" dir "${NAME}")
+ string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
+ add_test(
+ NAME ecm_add_tests-${NAME}
+ COMMAND
+ ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/${dir}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${dir}"
+ --build-two-config
+ --build-generator ${CMAKE_GENERATOR}
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-project ${proj}
+ --build-options -DBUILD_TESTING:BOOL=ON
+ ${${NAME}_EXTRA_OPTIONS}
+ --test-command "${CMAKE_CTEST_COMMAND}"
+ )
+ add_test(
+ NAME ecm_add_tests_did_run-${NAME}
+ COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/check_files.cmake" ${ARGN}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${dir}"
+ )
+ set_property(TEST ecm_add_tests_did_run-${NAME}
+ APPEND
+ PROPERTY DEPENDS "ecm_add_tests-${NAME}"
+ )
+endmacro()
+
+add_check(single_tests
+ test1.txt
+ test2.txt
+ test3.txt
+ test4.txt
+ test5.txt
+ test6.txt
+ )
+add_check(multi_tests
+ test1.txt
+ test2.txt
+ test3.txt
+ test4.txt
+ test5.txt
+ test6.txt
+ test7.txt
+ test8.txt
+ test9.txt
+ )
+
diff --git a/tests/ECMAddTests/check_files.cmake b/tests/ECMAddTests/check_files.cmake
new file mode 100644
index 00000000..fc6003c6
--- /dev/null
+++ b/tests/ECMAddTests/check_files.cmake
@@ -0,0 +1,15 @@
+set(i 0)
+set(in_file_args FALSE)
+while (i LESS CMAKE_ARGC)
+ if (in_file_args)
+ if (NOT EXISTS "${CMAKE_ARGV${i}}")
+ message(FATAL_ERROR "${CMAKE_ARGV${i}} does not exist")
+ endif()
+ elseif (CMAKE_ARGV${i} STREQUAL "-P")
+ # skip script name
+ math(EXPR i "${i} + 1")
+ set(in_file_args TRUE)
+ endif()
+ math(EXPR i "${i} + 1")
+endwhile()
+
diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt
new file mode 100644
index 00000000..0133c7d6
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt
@@ -0,0 +1,155 @@
+project(ECMAddTests)
+cmake_minimum_required(VERSION 2.8.12)
+
+set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+set(CMAKE_MODULE_PATH "${ECM_MODULE_DIR}")
+
+add_library(testhelper STATIC ../testhelper.cpp)
+target_include_directories(testhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+enable_testing()
+
+include(ECMAddTests)
+include(../../test_helpers.cmake)
+
+# clean up to avoid false-positives from check_files.cmake
+file(REMOVE
+ "${CMAKE_CURRENT_BINARY_DIR}/test1.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test2.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test3.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test4.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test5.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test6.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test7.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test8.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test9.txt"
+ )
+
+set(exp_target_names "test1;test2;test3")
+set(exp_test_names "test1;test2;test3")
+ecm_add_tests(
+ test1.cpp
+ test2.cpp
+ test3.cpp
+ LINK_LIBRARIES testhelper
+ TARGET_NAMES_VAR target_names
+ TEST_NAMES_VAR test_names
+ )
+assert_vars_setequal(target_names exp_target_names)
+assert_vars_setequal(test_names exp_test_names)
+# check targets exist
+get_property(_dummy TARGET test1 PROPERTY TYPE)
+get_property(_dummy TARGET test2 PROPERTY TYPE)
+get_property(_dummy TARGET test3 PROPERTY TYPE)
+# check tests exists
+get_property(_dummy TEST test1 PROPERTY TIMEOUT)
+get_property(_dummy TEST test2 PROPERTY TIMEOUT)
+get_property(_dummy TEST test3 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "test1 is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "test1 is an OS/X bundle when it should not be")
+endif()
+get_property(_is_win32 TARGET test2 PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "test2 is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET test2 PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "test2 is an OS/X bundle when it should not be")
+endif()
+
+
+ecm_add_tests(
+ test4.cpp
+ test5.cpp
+ LINK_LIBRARIES testhelper
+ NAME_PREFIX pref_
+ )
+get_property(_dummy TARGET test4 PROPERTY TYPE)
+get_property(_dummy TARGET test5 PROPERTY TYPE)
+get_property(_dummy TEST pref_test4 PROPERTY TIMEOUT)
+get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "test4 is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "test4 is an OS/X bundle when it should not be")
+endif()
+get_property(_is_win32 TARGET test5 PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "test5 is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET test5 PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "test5 is an OS/X bundle when it should not be")
+endif()
+
+
+ecm_add_tests(
+ test6.cpp
+ test7.cpp
+ LINK_LIBRARIES testhelper
+ GUI
+ )
+get_property(_dummy TARGET test6 PROPERTY TYPE)
+get_property(_dummy TARGET test7 PROPERTY TYPE)
+get_property(_dummy TEST test6 PROPERTY TIMEOUT)
+get_property(_dummy TEST test7 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test6 PROPERTY WIN32_EXECUTABLE)
+if (NOT _is_win32)
+ message(FATAL_ERROR "test6 is not a WIN32 executable when it should be")
+endif()
+get_property(_is_bundle TARGET test6 PROPERTY MACOSX_BUNDLE)
+if (NOT _is_bundle)
+ message(FATAL_ERROR "test6 is not an OS/X bundle when it should be")
+endif()
+get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE)
+if (NOT _is_win32)
+ message(FATAL_ERROR "test7 is not a WIN32 executable when it should be")
+endif()
+get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE)
+if (NOT _is_bundle)
+ message(FATAL_ERROR "test7 is not an OS/X bundle when it should be")
+endif()
+
+
+set(exp_target_names "test8;test9")
+set(exp_test_names "p_test8;p_test9")
+ecm_add_tests(
+ test8.cpp
+ test9.cpp
+ LINK_LIBRARIES testhelper
+ NAME_PREFIX p_
+ GUI
+ TARGET_NAMES_VAR target_names
+ TEST_NAMES_VAR test_names
+ )
+assert_vars_setequal(target_names exp_target_names)
+assert_vars_setequal(test_names exp_test_names)
+get_property(_dummy TARGET test8 PROPERTY TYPE)
+get_property(_dummy TARGET test9 PROPERTY TYPE)
+get_property(_dummy TEST p_test8 PROPERTY TIMEOUT)
+get_property(_dummy TEST p_test9 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test8 PROPERTY WIN32_EXECUTABLE)
+if (NOT _is_win32)
+ message(FATAL_ERROR "test8 is not a WIN32 executable when it should be")
+endif()
+get_property(_is_bundle TARGET test8 PROPERTY MACOSX_BUNDLE)
+if (NOT _is_bundle)
+ message(FATAL_ERROR "test8 is not an OS/X bundle when it should be")
+endif()
+get_property(_is_win32 TARGET test9 PROPERTY WIN32_EXECUTABLE)
+if (NOT _is_win32)
+ message(FATAL_ERROR "test9 is not a WIN32 executable when it should be")
+endif()
+get_property(_is_bundle TARGET test9 PROPERTY MACOSX_BUNDLE)
+if (NOT _is_bundle)
+ message(FATAL_ERROR "test9 is not an OS/X bundle when it should be")
+endif()
+
diff --git a/tests/ECMAddTests/multi_tests/test1.cpp b/tests/ECMAddTests/multi_tests/test1.cpp
new file mode 100644
index 00000000..e5482865
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test1.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test1.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test2.cpp b/tests/ECMAddTests/multi_tests/test2.cpp
new file mode 100644
index 00000000..7f45bb56
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test2.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test2.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test3.cpp b/tests/ECMAddTests/multi_tests/test3.cpp
new file mode 100644
index 00000000..142b2765
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test3.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test3.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test4.cpp b/tests/ECMAddTests/multi_tests/test4.cpp
new file mode 100644
index 00000000..1ba9b148
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test4.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test4.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test5.cpp b/tests/ECMAddTests/multi_tests/test5.cpp
new file mode 100644
index 00000000..987af36b
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test5.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test5.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test6.cpp b/tests/ECMAddTests/multi_tests/test6.cpp
new file mode 100644
index 00000000..6bda9f0d
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test6.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test6.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test7.cpp b/tests/ECMAddTests/multi_tests/test7.cpp
new file mode 100644
index 00000000..069859e7
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test7.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test7.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test8.cpp b/tests/ECMAddTests/multi_tests/test8.cpp
new file mode 100644
index 00000000..ce762c8d
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test8.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test8.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/multi_tests/test9.cpp b/tests/ECMAddTests/multi_tests/test9.cpp
new file mode 100644
index 00000000..e432aeba
--- /dev/null
+++ b/tests/ECMAddTests/multi_tests/test9.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test9.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/CMakeLists.txt b/tests/ECMAddTests/single_tests/CMakeLists.txt
new file mode 100644
index 00000000..6af3857b
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/CMakeLists.txt
@@ -0,0 +1,122 @@
+project(ECMAddTests)
+cmake_minimum_required(VERSION 2.8.12)
+
+set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+set(CMAKE_MODULE_PATH "${ECM_MODULE_DIR}")
+
+add_library(testhelper STATIC ../testhelper.cpp)
+target_include_directories(testhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+enable_testing()
+
+include(ECMAddTests)
+
+# clean up to avoid false-positives from check_files.cmake
+file(REMOVE
+ "${CMAKE_CURRENT_BINARY_DIR}/test1.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test2.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test3.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test4.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test5.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/test6.txt"
+ )
+
+ecm_add_test(test1.cpp
+ LINK_LIBRARIES testhelper
+ )
+# check target exists
+get_property(_dummy TARGET test1 PROPERTY TYPE)
+# check test exists
+get_property(_dummy TEST test1 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "test1 is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "test1 is an OS/X bundle when it should not be")
+endif()
+
+
+ecm_add_test(test2.cpp
+ LINK_LIBRARIES testhelper
+ TEST_NAME named_test
+ )
+get_property(_dummy TARGET named_test PROPERTY TYPE)
+get_property(_dummy TEST named_test PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET named_test PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "named_test is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET named_test PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "named_test is an OS/X bundle when it should not be")
+endif()
+
+
+ecm_add_test(test3.cpp
+ LINK_LIBRARIES testhelper
+ NAME_PREFIX prefix_
+ )
+get_property(_dummy TARGET test3 PROPERTY TYPE)
+get_property(_dummy TEST prefix_test3 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "test3 is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET test3 PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "test3 is an OS/X bundle when it should not be")
+endif()
+
+
+ecm_add_test(test4.cpp
+ LINK_LIBRARIES testhelper
+ GUI
+ )
+get_property(_dummy TARGET test4 PROPERTY TYPE)
+get_property(_dummy TEST test4 PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE)
+if (NOT _is_win32)
+ message(FATAL_ERROR "test4 is not a WIN32 executable when it should be")
+endif()
+get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE)
+if (NOT _is_bundle)
+ message(FATAL_ERROR "test4 is not an OS/X bundle when it should be")
+endif()
+
+
+ecm_add_test(test5.cpp
+ LINK_LIBRARIES testhelper
+ TEST_NAME combined_test
+ NAME_PREFIX another_prefix_
+ GUI
+ )
+get_property(_dummy TARGET combined_test PROPERTY TYPE)
+get_property(_dummy TEST another_prefix_combined_test PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET combined_test PROPERTY WIN32_EXECUTABLE)
+if (NOT _is_win32)
+ message(FATAL_ERROR "combined_test is not a WIN32 executable when it should be")
+endif()
+get_property(_is_bundle TARGET combined_test PROPERTY MACOSX_BUNDLE)
+if (NOT _is_bundle)
+ message(FATAL_ERROR "combined_test is not an OS/X bundle when it should be")
+endif()
+
+
+ecm_add_test(test6.cpp test6body.cpp
+ LINK_LIBRARIES testhelper
+ TEST_NAME multifile_test
+ )
+get_property(_dummy TARGET multifile_test PROPERTY TYPE)
+get_property(_dummy TEST multifile_test PROPERTY TIMEOUT)
+get_property(_is_win32 TARGET multifile_test PROPERTY WIN32_EXECUTABLE)
+if (_is_win32)
+ message(FATAL_ERROR "multifile_test is a WIN32 executable when it should not be")
+endif()
+get_property(_is_bundle TARGET multifile_test PROPERTY MACOSX_BUNDLE)
+if (_is_bundle)
+ message(FATAL_ERROR "multifile_test is an OS/X bundle when it should not be")
+endif()
+
+
diff --git a/tests/ECMAddTests/single_tests/test1.cpp b/tests/ECMAddTests/single_tests/test1.cpp
new file mode 100644
index 00000000..e5482865
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test1.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test1.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/test2.cpp b/tests/ECMAddTests/single_tests/test2.cpp
new file mode 100644
index 00000000..7f45bb56
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test2.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test2.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/test3.cpp b/tests/ECMAddTests/single_tests/test3.cpp
new file mode 100644
index 00000000..142b2765
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test3.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test3.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/test4.cpp b/tests/ECMAddTests/single_tests/test4.cpp
new file mode 100644
index 00000000..1ba9b148
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test4.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test4.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/test5.cpp b/tests/ECMAddTests/single_tests/test5.cpp
new file mode 100644
index 00000000..987af36b
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test5.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+
+int main()
+{
+ make_test_file("test5.txt");
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/test6.cpp b/tests/ECMAddTests/single_tests/test6.cpp
new file mode 100644
index 00000000..33cd0421
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test6.cpp
@@ -0,0 +1,8 @@
+void test_body();
+
+int main()
+{
+ test_body();
+ return 0;
+}
+
diff --git a/tests/ECMAddTests/single_tests/test6body.cpp b/tests/ECMAddTests/single_tests/test6body.cpp
new file mode 100644
index 00000000..c3332738
--- /dev/null
+++ b/tests/ECMAddTests/single_tests/test6body.cpp
@@ -0,0 +1,7 @@
+#include "testhelper.h"
+
+void test_body()
+{
+ make_test_file("test6.txt");
+}
+
diff --git a/tests/ECMAddTests/testhelper.cpp b/tests/ECMAddTests/testhelper.cpp
new file mode 100644
index 00000000..00d0ceed
--- /dev/null
+++ b/tests/ECMAddTests/testhelper.cpp
@@ -0,0 +1,8 @@
+#include "testhelper.h"
+#include <fstream>
+#include <string>
+
+void make_test_file(const char *filename)
+{
+ std::ofstream(filename) << "test" << std::endl;
+}
diff --git a/tests/ECMAddTests/testhelper.h b/tests/ECMAddTests/testhelper.h
new file mode 100644
index 00000000..9810ee41
--- /dev/null
+++ b/tests/ECMAddTests/testhelper.h
@@ -0,0 +1 @@
+void make_test_file(const char *filename);
diff --git a/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h
diff --git a/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h
diff --git a/tests/ECMGenerateHeadersTest/CommonHeader b/tests/ECMGenerateHeadersTest/CommonHeader
new file mode 100644
index 00000000..0d101fbc
--- /dev/null
+++ b/tests/ECMGenerateHeadersTest/CommonHeader
@@ -0,0 +1,4 @@
+// convenience header
+#include "headtest1.h"
+#include "headtest2.h"
+#include "headtest4.h"
diff --git a/tests/ECMGenerateHeadersTest/headtest4.h b/tests/ECMGenerateHeadersTest/headtest4.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/ECMGenerateHeadersTest/headtest4.h
diff --git a/tests/ECMGenerateHeadersTest/run_test.cmake.config b/tests/ECMGenerateHeadersTest/run_test.cmake.config
index 0a2425fe..a9027dbc 100644
--- a/tests/ECMGenerateHeadersTest/run_test.cmake.config
+++ b/tests/ECMGenerateHeadersTest/run_test.cmake.config
@@ -244,4 +244,114 @@ check_files(GENERATED ${expfiles}
ORIGINALS ${origfiles})
+###########################################################
+
+message(STATUS "Test 10: ORIGINAL CAMELCASE")
+set(forward_headers)
+set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/CamelCaseHeadTest1"
+ "${CMAKE_CURRENT_BINARY_DIR}/CamelCaseHeadTest2")
+set(origfiles CamelCaseHeadTest1.h CamelCaseHeadTest2.h)
+file(REMOVE ${expfiles})
+ecm_generate_headers(
+ forward_headers
+ ORIGINAL CAMELCASE
+ HEADER_NAMES CamelCaseHeadTest1 CamelCaseHeadTest2
+)
+if (NOT "${expfiles}" STREQUAL "${forward_headers}")
+ message(FATAL_ERROR "forward_headers was set to \"${forward_headers}\" instead of \"${expfiles}\"")
+endif()
+check_files(GENERATED ${expfiles}
+ ORIGINALS ${origfiles})
+
+
+###########################################################
+
+message(STATUS "Test 11: PREFIX and ORIGINAL CAMELCASE")
+set(forward_headers)
+set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/Module/CamelCaseHeadTest1"
+ "${CMAKE_CURRENT_BINARY_DIR}/Module/CamelCaseHeadTest2")
+set(intermediatefiles Module/CamelCaseHeadTest1.h Module/CamelCaseHeadTest2.h)
+set(origfiles "${CMAKE_CURRENT_SOURCE_DIR}/headtest1.h"
+ "${CMAKE_CURRENT_SOURCE_DIR}/headtest2.h")
+file(REMOVE ${expfiles} ${intermediatefiles})
+ecm_generate_headers(
+ forward_headers
+ ORIGINAL CAMELCASE
+ HEADER_NAMES CamelCaseHeadTest1 CamelCaseHeadTest2
+ PREFIX Module
+)
+if (NOT "${expfiles}" STREQUAL "${forward_headers}")
+ message(FATAL_ERROR "forward_headers was set to \"${forward_headers}\" instead of \"${expfiles}\"")
+endif()
+check_files(GENERATED ${expfiles}
+ ORIGINALS ${intermediatefiles})
+check_files(GENERATED ${expfiles}
+ ORIGINALS ${intermediatefiles})
+
+###########################################################
+
+message(STATUS "Test 12: COMMON_HEADER")
+
+set(camelcase_headers)
+set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/HeadTest1"
+ "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2"
+ "${CMAKE_CURRENT_BINARY_DIR}/HeadTest4"
+ "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader")
+set(origfiles headtest1.h headtest2.h)
+file(REMOVE ${expfiles})
+ecm_generate_headers(
+ camelcase_headers
+ ORIGINAL LOWERCASE
+ HEADER_NAMES HeadTest1 HeadTest2 HeadTest4
+ COMMON_HEADER CommonHeader
+)
+if (NOT "${expfiles}" STREQUAL "${camelcase_headers}")
+ message(FATAL_ERROR "camelcase_headers was set to \"${camelcase_headers}\" instead of \"${expfiles}\"")
+endif()
+check_files(GENERATED ${expfiles}
+ ORIGINALS ${origfiles})
+
+file(READ CommonHeader file_contents)
+string(STRIP "${file_contents}" file_contents)
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader" exp_contents)
+string(STRIP "${exp_contents}" exp_contents)
+if (NOT "${file_contents}" STREQUAL "${exp_contents}")
+ message(FATAL_ERROR "${generated_file} contains '${file_contents}' instead of '${exp_contents}'")
+endif()
+
+
+###########################################################
+
+message(STATUS "Test 13: multiple classes and COMMON_HEADER")
+
+set(camelcase_headers)
+set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/HeadTest1"
+ "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2"
+ "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2Add1"
+ "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2Add2"
+ "${CMAKE_CURRENT_BINARY_DIR}/HeadTest4"
+ "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader")
+set(origfiles headtest1.h headtest2.h headtest4.h)
+file(REMOVE ${expfiles})
+ecm_generate_headers(
+ camelcase_headers
+ ORIGINAL LOWERCASE
+ HEADER_NAMES HeadTest1 HeadTest2,HeadTest2Add1,HeadTest2Add2 HeadTest4
+ COMMON_HEADER CommonHeader
+)
+if (NOT "${expfiles}" STREQUAL "${camelcase_headers}")
+ message(FATAL_ERROR "camelcase_headers was set to \"${camelcase_headers}\" instead of \"${expfiles}\"")
+endif()
+check_files(GENERATED ${expfiles}
+ ORIGINALS ${origfiles})
+
+file(READ CommonHeader file_contents)
+string(STRIP "${file_contents}" file_contents)
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader" exp_contents)
+string(STRIP "${exp_contents}" exp_contents)
+if (NOT "${file_contents}" STREQUAL "${exp_contents}")
+ message(FATAL_ERROR "${generated_file} contains '${file_contents}' instead of '${exp_contents}'")
+endif()
+
+
# vim:ft=cmake
diff --git a/tests/ECMGeneratePkgConfigFile/CMakeLists.txt b/tests/ECMGeneratePkgConfigFile/CMakeLists.txt
index 9f407cb0..f3bc267d 100644
--- a/tests/ECMGeneratePkgConfigFile/CMakeLists.txt
+++ b/tests/ECMGeneratePkgConfigFile/CMakeLists.txt
@@ -2,5 +2,5 @@ set(MODULES_DIR "${extra-cmake-modules_SOURCE_DIR}/modules")
configure_file(run_test.cmake.config "${CMAKE_CURRENT_BINARY_DIR}/run_test.cmake" @ONLY)
add_test(
- NAME ECMGenerateHeaders
+ NAME ECMGeneratePkgConfigFile
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/run_test.cmake")
diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt
index 85f2d9f5..f048889e 100644
--- a/tests/ECMInstallIconsTest/CMakeLists.txt
+++ b/tests/ECMInstallIconsTest/CMakeLists.txt
@@ -10,6 +10,7 @@ include(ECMInstallIcons)
add_subdirectory(v1-syntax)
add_subdirectory(v1-syntax-l10n)
+add_subdirectory(v1-syntax-no-icons)
ecm_install_icons(
ICONS 16-actions-computer.png
@@ -20,7 +21,7 @@ ecm_install_icons(
ICONS
16-actions-computer.png
16-animations-loading.mng
- 16-apps-cmake.png
+ subdir/16-apps-cmake.png
16-categories-system-help.mng
16-emotes-face-smile.png
16-intl-something.png
@@ -36,7 +37,7 @@ ecm_install_icons(
ICONS
16-actions-computer.png
16-animations-loading.mng
- 16-apps-cmake.png
+ subdir/16-apps-cmake.png
16-categories-system-help.mng
16-emotes-face-smile.png
16-intl-something.png
@@ -53,7 +54,7 @@ ecm_install_icons(
ICONS
16-actions-computer.png
16-animations-loading.mng
- 16-apps-cmake.png
+ subdir/16-apps-cmake.png
16-categories-system-help.mng
16-emotes-face-smile.png
16-intl-something.png
@@ -70,7 +71,7 @@ ecm_install_icons(
ICONS
16-actions-computer.png
16-animations-loading.mng
- 16-apps-cmake.png
+ subdir/16-apps-cmake.png
16-categories-system-help.mng
16-emotes-face-smile.png
16-intl-something.png
@@ -87,11 +88,19 @@ ecm_install_icons(
# all these should be warned about
ecm_install_icons(
ICONS
- aa-actions-badsize.png # ignored
- badlynamedfile.png # ignored
- 16-actions-badext.txt # copied
+ aa-actions-badsize.png # ignored
+ badlynamedfile.png # ignored
+ 16-actions-badext.txt # copied
+ hi16-actions-old-style-name.png # copied
DESTINATION badly-named-files-test
)
+find_program(icon_cache_generator NAMES gtk-update-icon-cache)
+if (icon_cache_generator)
+ set(GENERATE_ICON_CACHE TRUE)
+else()
+ set(GENERATE_ICON_CACHE FALSE)
+endif()
+
# this will be run by CTest
configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY)
diff --git a/tests/ECMInstallIconsTest/check_tree.cmake.in b/tests/ECMInstallIconsTest/check_tree.cmake.in
index 6d14246b..b9da1715 100644
--- a/tests/ECMInstallIconsTest/check_tree.cmake.in
+++ b/tests/ECMInstallIconsTest/check_tree.cmake.in
@@ -1,8 +1,15 @@
set(EXP_TREE "@CMAKE_CURRENT_SOURCE_DIR@/expected-tree")
set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@")
+set(GENERATE_ICON_CACHE "@GENERATE_ICON_CACHE@")
file(GLOB_RECURSE exp_files RELATIVE "${EXP_TREE}" "${EXP_TREE}/*")
file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*")
+if (NOT GENERATE_ICON_CACHE)
+ file(GLOB_RECURSE cache_files RELATIVE "${EXP_TREE}" "${EXP_TREE}/*.cache")
+ foreach(f ${cache_files})
+ list(REMOVE_ITEM exp_files "${f}")
+ endforeach()
+endif()
list(SORT exp_files)
list(SORT actual_files)
diff --git a/tests/ECMInstallIconsTest/16-apps-cmake.png b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png
index ed9a1181..ed9a1181 100644
--- a/tests/ECMInstallIconsTest/16-apps-cmake.png
+++ b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache
new file mode 100644
index 00000000..50d52976
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache
new file mode 100644
index 00000000..babadff0
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache
new file mode 100644
index 00000000..60ac05d6
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache
new file mode 100644
index 00000000..f385659f
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache
new file mode 100644
index 00000000..babadff0
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache
new file mode 100644
index 00000000..60ac05d6
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache
new file mode 100644
index 00000000..8b9c8d0c
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache
new file mode 100644
index 00000000..ab56337b
--- /dev/null
+++ b/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache
Binary files differ
diff --git a/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png b/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png
new file mode 100644
index 00000000..ed9a1181
--- /dev/null
+++ b/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png
Binary files differ
diff --git a/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png b/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png
new file mode 100644
index 00000000..ed9a1181
--- /dev/null
+++ b/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png
Binary files differ
diff --git a/tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt b/tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt
new file mode 100644
index 00000000..e0cacec2
--- /dev/null
+++ b/tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt
@@ -0,0 +1 @@
+ecm_install_icons(v1-icons-dummy)
diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt
index 15351d2f..76d80141 100644
--- a/tests/ECMPoQmToolsTest/CMakeLists.txt
+++ b/tests/ECMPoQmToolsTest/CMakeLists.txt
@@ -9,9 +9,13 @@ file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}")
include(ECMPoQmTools)
-# Should create ${CMAKE_CURRENT_BINARY_DIR}/qmloader.cpp and set QMLOADER_PATH
-# to its path
-ecm_create_qm_loader(QMLOADER_PATH catalog)
+include(../test_helpers.cmake)
+
+
+#
+# ecm_process_po_files_as_qm
+#
+
# Should create a process-and-install.qm file and install it
ecm_process_po_files_as_qm(fr ALL
@@ -24,20 +28,63 @@ ecm_process_po_files_as_qm(fr ALL
PO_FILES only-process.po
)
+
+
+#
+# ecm_install_po_files_as_qm
+#
+
# Should create a bunch of .qm files and install them in share/locale.
# Should ignore files directly under po/ as well as directories under po/ which
# do not contain any .po files.
ecm_install_po_files_as_qm(po)
+
# Should create a bunch of .qm files and install them in
# ${CMAKE_INSTALL_LOCALEDIR}
set(CMAKE_INSTALL_LOCALEDIR custom-dir1)
ecm_install_po_files_as_qm(po-custom-dir1)
+
# Should create a bunch of .qm files and install them in
# ${LOCALE_INSTALL_DIR}
set(LOCALE_INSTALL_DIR custom-dir2)
ecm_install_po_files_as_qm(po-custom-dir2)
-# this will be run by CTest
-configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY)
+unset(CMAKE_INSTALL_LOCALEDIR)
+unset(LOCALE_INSTALL_DIR)
+
+
+
+#
+# ecm_create_qm_loader
+#
+
+find_package(Qt5Core CONFIG REQUIRED)
+ecm_install_po_files_as_qm(tr_test-po)
+
+
+set(tr_test_SRCS
+ tr_test.cpp
+)
+ecm_create_qm_loader(tr_test_SRCS catalog)
+add_executable(tr_test ${tr_test_SRCS})
+target_link_libraries(tr_test PRIVATE Qt5::Core)
+
+
+# This is not something we want people to do (putting the ecm_create_qm_loader
+# call in one CMakeLists.txt file and the target it is used for in another),
+# but it's unfortunately something projects have done and we need to keep them
+# building
+unset(QMLOADER_FILES)
+ecm_create_qm_loader(QMLOADER_FILES catalog)
+assert_var_defined(QMLOADER_FILES)
+add_subdirectory(subdir)
+
+
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check_conf.cmake"
+ INPUT "${CMAKE_CURRENT_SOURCE_DIR}/check_conf.cmake.in"
+)
+configure_file(check.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check.cmake" @ONLY)
diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in
index 9f4f7c0d..ab434d2e 100644
--- a/tests/ECMPoQmToolsTest/check_tree.cmake.in
+++ b/tests/ECMPoQmToolsTest/check.cmake.in
@@ -1,6 +1,6 @@
set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@")
-set(QMLOADER_PATH "@QMLOADER_PATH@")
+include("${BINARY_DIR}/check_conf.cmake")
set(fail OFF)
@@ -9,27 +9,21 @@ macro(mark_failed msg)
set(fail ON)
endmacro()
-macro(check_strequal var expected)
- if (NOT "${${var}}" STREQUAL "${expected}")
- mark_failed("${var} is:\n \"${${var}}\"\nExpected:\n \"${expected}\"")
- endif()
-endmacro()
-
macro(check_exists file)
+ message(STATUS "Checking for ${file}")
if (NOT EXISTS ${file})
mark_failed("File \"${file}\" does not exist")
endif()
endmacro()
-check_exists(${BINARY_DIR}/ECMQmLoader.cpp)
-check_strequal(QMLOADER_PATH "${BINARY_DIR}/ECMQmLoader.cpp")
-
check_exists(${BINARY_DIR}/fr/only-process.qm)
set(exp_files
"share/locale/fr/LC_MESSAGES/process-and-install.qm"
"share/locale/es/LC_MESSAGES/install-test.qm"
"share/locale/fr/LC_MESSAGES/install-test.qm"
+ "share/locale/en/LC_MESSAGES/catalog.qm"
+ "share/locale/de/LC_MESSAGES/catalog.qm"
"custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm"
"custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm"
"custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm"
@@ -54,6 +48,32 @@ if(NOT exp_files STREQUAL actual_files)
set(fail ON)
endif()
endforeach()
+else()
+ message(STATUS "Installed translations in expected locations")
+endif()
+
+# we know we can modify the executable environment on Linux
+if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux")
+ set(exp_output_en "english text:english plural form 5")
+ set(exp_output_de "german text:german plural form 5")
+ # no french translation provided -> english fallback
+ set(exp_output_fr "${exp_output_en}")
+ foreach(exec TR_TEST TR_TEST_SUBDIR)
+ foreach(lang en de fr)
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share"
+ LANGUAGE=${lang} "${${exec}_EXEC}"
+ OUTPUT_VARIABLE output
+ )
+ string(STRIP "${output}" stripped_output)
+ if(NOT stripped_output STREQUAL exp_output_${lang})
+ message(WARNING "${exec}[${lang}] output was \"${stripped_output}\", but expected \"${exp_output_${lang}}\"")
+ set(fail ON)
+ else()
+ message(STATUS "${exec}[${lang}] output was \"${stripped_output}\", as expected")
+ endif()
+ endforeach()
+ endforeach()
endif()
if (fail)
diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in
new file mode 100644
index 00000000..9ab02e72
--- /dev/null
+++ b/tests/ECMPoQmToolsTest/check_conf.cmake.in
@@ -0,0 +1,2 @@
+set(TR_TEST_EXEC "$<TARGET_FILE:tr_test>")
+set(TR_TEST_SUBDIR_EXEC "$<TARGET_FILE:tr_test_subdir>")
diff --git a/tests/ECMPoQmToolsTest/subdir/CMakeLists.txt b/tests/ECMPoQmToolsTest/subdir/CMakeLists.txt
new file mode 100644
index 00000000..ee06b971
--- /dev/null
+++ b/tests/ECMPoQmToolsTest/subdir/CMakeLists.txt
@@ -0,0 +1,5 @@
+# QMLOADER_FILES comes from parent CMakeLists.txt. This is not something we
+# want people to do, but it's unfortunately something projects have done and we
+# need to keep them building
+add_executable(tr_test_subdir ../tr_test.cpp ${QMLOADER_FILES})
+target_link_libraries(tr_test_subdir PRIVATE Qt5::Core)
diff --git a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po
new file mode 100644
index 00000000..6f3e328f
--- /dev/null
+++ b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Language: de\n"
+"X-Qt-Contexts: true\n"
+
+#: main.cpp:12
+msgctxt "testcontext|"
+msgid "test string"
+msgstr "german text"
+
+#: main.cpp:13
+#, qt-format
+#| msgid "test plural"
+msgctxt "testcontext|"
+msgid "test plural %n"
+msgid_plural "test plural %n"
+msgstr[0] "german singular form %n"
+msgstr[1] "german plural form %n"
diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po
new file mode 100644
index 00000000..2a7b6d28
--- /dev/null
+++ b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Language: en\n"
+"X-Qt-Contexts: true\n"
+
+#: main.cpp:12
+msgctxt "testcontext|"
+msgid "test string"
+msgstr "english text"
+
+#: main.cpp:13
+#, qt-format
+#| msgid "test plural"
+msgctxt "testcontext|"
+msgid "test plural %n"
+msgid_plural "test plural %n"
+msgstr[0] "english singular form %n"
+msgstr[1] "english plural form %n"
diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp
new file mode 100644
index 00000000..22101263
--- /dev/null
+++ b/tests/ECMPoQmToolsTest/tr_test.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Alex Merry <alex.merry@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <QCoreApplication>
+#include <QTextStream>
+
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QTextStream output(stdout);
+
+ output << QCoreApplication::translate("testcontext", "test string") << ":";
+ output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n';
+
+ return 0;
+}
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
new file mode 100644
index 00000000..15ece187
--- /dev/null
+++ b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
@@ -0,0 +1,42 @@
+project(ECMQtDeclareLoggingCategoryTest)
+cmake_minimum_required(VERSION 2.8.12)
+set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../modules")
+
+set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR})
+
+include(ECMQtDeclareLoggingCategory)
+
+ecm_qt_declare_logging_category(
+ sources
+ HEADER "log1.h"
+ IDENTIFIER "log1"
+ CATEGORY_NAME "log.one"
+)
+
+ecm_qt_declare_logging_category(
+ sources
+ HEADER "log2.h"
+ IDENTIFIER "foo::bar::log2"
+ CATEGORY_NAME "log.two"
+)
+
+ecm_qt_declare_logging_category(
+ sources
+ HEADER "${CMAKE_CURRENT_BINARY_DIR}/log3.h"
+ IDENTIFIER "log3"
+ CATEGORY_NAME "three"
+ DEFAULT_SEVERITY Critical
+)
+
+find_package(Qt5Core REQUIRED)
+
+add_executable(testmain testmain.cpp ${sources})
+target_include_directories(testmain
+ PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}"
+)
+target_link_libraries(testmain
+ PRIVATE
+ Qt5::Core
+)
+
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp
new file mode 100644
index 00000000..4abcd527
--- /dev/null
+++ b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp
@@ -0,0 +1,108 @@
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <QCoreApplication>
+
+#include "log1.h"
+#include "log2.h"
+#include "log3.h"
+
+#include <iostream>
+
+int main(int argc, char **argv) {
+ QCoreApplication qapp(argc, argv);
+
+ bool success = true;
+
+ // NB: we cannot test against QtInfoMsg, as that (a) does not exist before
+ // Qt 5.5, and (b) has incorrect semantics in Qt 5.5, in that it is
+ // treated as more severe than QtCriticalMsg.
+
+ if (log1().categoryName() != QLatin1String("log.one")) {
+ qWarning("log1 category was \"%s\", expected \"log.one\"", log1().categoryName());
+ success = false;
+ }
+#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
+ if (!log1().isDebugEnabled()) {
+ qWarning("log1 debug messages were not enabled");
+ success = false;
+ }
+#else
+ if (log1().isDebugEnabled()) {
+ qWarning("log1 debug messages were enabled");
+ success = false;
+ }
+ if (!log1().isWarningEnabled()) {
+ qWarning("log1 warning messages were not enabled");
+ success = false;
+ }
+#endif
+
+ if (foo::bar::log2().categoryName() != QLatin1String("log.two")) {
+ qWarning("log2 category was \"%s\", expected \"log.two\"", foo::bar::log2().categoryName());
+ success = false;
+ }
+#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
+ if (!foo::bar::log2().isDebugEnabled()) {
+ qWarning("log2 debug messages were not enabled");
+ success = false;
+ }
+#else
+ if (foo::bar::log2().isDebugEnabled()) {
+ qWarning("log2 debug messages were enabled");
+ success = false;
+ }
+ if (!foo::bar::log2().isWarningEnabled()) {
+ qWarning("log2 warning messages were not enabled");
+ success = false;
+ }
+#endif
+
+ if (log3().categoryName() != QLatin1String("three")) {
+ qWarning("log3 category was \"%s\", expected \"three\"", log3().categoryName());
+ success = false;
+ }
+#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
+ if (!log3().isDebugEnabled()) {
+ qWarning("log3 debug messages were not enabled");
+ success = false;
+ }
+#else
+ if (log3().isDebugEnabled()) {
+ qWarning("log3 debug messages were enabled");
+ success = false;
+ }
+ if (log3().isWarningEnabled()) {
+ qWarning("log3 warning messages were enabled");
+ success = false;
+ }
+ if (!log3().isCriticalEnabled()) {
+ qWarning("log3 critical messages were not enabled");
+ success = false;
+ }
+#endif
+
+ return success ? 0 : 1;
+}
diff --git a/tests/ExecuteKDEModules/CMakeLists.txt b/tests/ExecuteKDEModules/CMakeLists.txt
index d70ea908..69a19a31 100644
--- a/tests/ExecuteKDEModules/CMakeLists.txt
+++ b/tests/ExecuteKDEModules/CMakeLists.txt
@@ -7,11 +7,12 @@ set(all_kde_modules
KDECMakeSettings
KDECompilerSettings
KDEFrameworkCompilerSettings
+ ECMMarkNonGuiExecutable
)
set(ECM_KDE_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../kde-modules)
set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../modules)
-set(CMAKE_MODULE_PATH "${ECM_KDE_MODULE_DIR}")
+set(CMAKE_MODULE_PATH "${ECM_KDE_MODULE_DIR}" "${ECM_MODULE_DIR}")
foreach(module ${all_kde_modules})
message(STATUS "module: ${module}")
@@ -19,4 +20,6 @@ foreach(module ${all_kde_modules})
endforeach()
add_executable(dummy main.c)
+ecm_mark_nongui_executable(dummy)
+
set_target_properties(dummy PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/tests/test_helpers.cmake b/tests/test_helpers.cmake
index 73be343e..d9314d25 100644
--- a/tests/test_helpers.cmake
+++ b/tests/test_helpers.cmake
@@ -62,3 +62,31 @@ macro(assert_var_absolute_path varname)
endif()
endmacro()
+function(assert_vars_setequal varname exp_varname)
+ if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED")
+ assert_var_defined(${varname})
+ endif()
+ # need real variables
+ set(list1 "${${varname}}")
+ set(list2 "${${exp_varname}}")
+ list(LENGTH list1 list1_len)
+ list(LENGTH list2 list2_len)
+ set(same_els FALSE)
+ if(list1_len EQUAL list2_len)
+ set(same_els TRUE)
+ foreach(item ${list1})
+ list(FIND list2 "${item}" pos)
+ if(pos EQUAL "-1")
+ set(same_els FALSE)
+ break()
+ else()
+ # deal nicely with duplicates
+ list(REMOVE_AT list2 "${pos}")
+ endif()
+ endforeach()
+ endif()
+ if(NOT same_els)
+ message(SEND_ERROR "${varname} is '${${varname}}', expecting '${${exp_varname}}'.")
+ endif()
+endfunction()
+