From 959c374c022394a116e8ceb2b1fce2df11752068 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 28 Dec 2014 15:03:07 +0000 Subject: Add SameMajorVersionWithPreleases compat option to ecm_setup_version. SameMajorVersionWithPreleases is intended implement the versioning scheme followed by many KDE projects: minor releases after some high number (eg: 90) are considered to be pre-releases of the next major version, and are not compatible with the current major version. This allows alpha and beta releases to be ordered correctly by version-number-aware software like package managers (an alpha of version 2 should have a higher number than any release of version 1, but less than version 2.0). So a request for version 2.1.0 of a piece of software should not be satisfied by 2.93.4, because that is actually a pre-release of version 3. On the other hand, a request for version 2.91.0 should be satisfied by version 3.1.0. Note that prereleases are not considered unless explicitly requested, so 2.93.4 will not satisfy requests for version 3 (or version 2) of a piece of software. --- tests/ECMSetupVersionTest/CMakeLists.txt | 1 + .../old_version_file_prereleases/CMakeLists.txt | 189 +++++++++++++++++++++ .../old_version_file_prereleases/main.c | 4 + tests/test_helpers.cmake | 4 +- 4 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt create mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/main.c (limited to 'tests') diff --git a/tests/ECMSetupVersionTest/CMakeLists.txt b/tests/ECMSetupVersionTest/CMakeLists.txt index b0845e57..c15af921 100644 --- a/tests/ECMSetupVersionTest/CMakeLists.txt +++ b/tests/ECMSetupVersionTest/CMakeLists.txt @@ -19,6 +19,7 @@ add_version_test(old_version_file dummy) add_version_test(old_version_file_abspath dummy) add_version_test(old_version_file_anynewer dummy) add_version_test(old_version_file_exact dummy) +add_version_test(old_version_file_prereleases dummy) add_version_test(old_version_file_samemajor dummy) add_version_test(old_header check_header) add_version_test(old_header_abspath check_header) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt b/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt new file mode 100644 index 00000000..e498fce6 --- /dev/null +++ b/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt @@ -0,0 +1,189 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(old_version_file_prereleases) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules) +include(ECMSetupVersion) + +ecm_setup_version(2.3.4 + VARIABLE_PREFIX Foo + PACKAGE_VERSION_FILE FooVersion.cmake + COMPATIBILITY SameMajorVersionWithPrereleases + FIRST_PRERELEASE_VERSION 90 +) + +include(../../test_helpers.cmake) +include(../version_helpers.cmake) + +macro(find_foo version) + test_version_file("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake" "${version}") + assert_var_str_value(PACKAGE_VERSION "2.3.4") +endmacro() + +standard_version_var_checks(Foo 2.3.4) + +# too old - fails +find_foo("3.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for wrong major version - fails +find_foo("2.90.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for correct major version - succeeds +find_foo("1.90") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for correct major version - succeeds +find_foo("1.90.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for correct major version - succeeds +find_foo("1.95.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, more recent - succeeds +find_foo("2.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version - succeeds +find_foo("2") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, but too old - fails +find_foo("2.4.4") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# exact - succeeds +find_foo("2.3.4") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) + + + + +ecm_setup_version(2.90.0 + VARIABLE_PREFIX Foo3Prerelease + PACKAGE_VERSION_FILE Foo3PrereleaseVersion.cmake + COMPATIBILITY SameMajorVersionWithPrereleases + FIRST_PRERELEASE_VERSION 90 +) + +macro(find_foo version) + test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3PrereleaseVersion.cmake" "${version}") + assert_var_str_value(PACKAGE_VERSION "2.90.0") +endmacro() + +standard_version_var_checks(Foo3Prerelease 2.90.0) + +# too old - fails +find_foo("3.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# too old - fails +find_foo("2.90.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, but don't want a prerelease - fails +find_foo("3") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2.89.9") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# exact version - succeeds +find_foo("2.90.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) + + + + +ecm_setup_version(2.93.4 + VARIABLE_PREFIX Foo3Prerelease2 + PACKAGE_VERSION_FILE Foo3Prerelease2Version.cmake + COMPATIBILITY SameMajorVersionWithPrereleases + FIRST_PRERELEASE_VERSION 90 +) + +macro(find_foo version) + test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3Prerelease2Version.cmake" "${version}") + assert_var_str_value(PACKAGE_VERSION "2.93.4") +endmacro() + +standard_version_var_checks(Foo3Prerelease2 2.93.4) + +# too old - fails +find_foo("3.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# too old - fails +find_foo("2.94.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, but don't want a prerelease - fails +find_foo("3") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2.89.9") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version - succeeds +find_foo("2.90.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# exact version - succeeds +find_foo("2.93.4") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) + +add_executable(dummy main.c) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c b/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c new file mode 100644 index 00000000..c13815ce --- /dev/null +++ b/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/tests/test_helpers.cmake b/tests/test_helpers.cmake index 73be343e..236a1868 100644 --- a/tests/test_helpers.cmake +++ b/tests/test_helpers.cmake @@ -38,9 +38,9 @@ macro(assert_var_bool_value varname value) assert_var_defined(${varname}) endif() if(${value} AND NOT ${varname}) - message(FATAL_ERROR "${varname} was FALSE") + message(SEND_ERROR "${varname} was FALSE") elseif(${varname} AND NOT ${value}) - message(FATAL_ERROR "${varname} was TRUE") + message(SEND_ERROR "${varname} was TRUE") endif() endmacro() -- cgit v1.2.1 From d609e598170064b4ee65392177a9d07f4302698d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 24 Jan 2015 14:47:59 +0000 Subject: Revert "Add SameMajorVersionWithPreleases compat option to ecm_setup_version." This reverts commit 959c374c022394a116e8ceb2b1fce2df11752068. I merged and pushed the wrong branch. --- tests/ECMSetupVersionTest/CMakeLists.txt | 1 - .../old_version_file_prereleases/CMakeLists.txt | 189 --------------------- .../old_version_file_prereleases/main.c | 4 - tests/test_helpers.cmake | 4 +- 4 files changed, 2 insertions(+), 196 deletions(-) delete mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt delete mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/main.c (limited to 'tests') diff --git a/tests/ECMSetupVersionTest/CMakeLists.txt b/tests/ECMSetupVersionTest/CMakeLists.txt index c15af921..b0845e57 100644 --- a/tests/ECMSetupVersionTest/CMakeLists.txt +++ b/tests/ECMSetupVersionTest/CMakeLists.txt @@ -19,7 +19,6 @@ add_version_test(old_version_file dummy) add_version_test(old_version_file_abspath dummy) add_version_test(old_version_file_anynewer dummy) add_version_test(old_version_file_exact dummy) -add_version_test(old_version_file_prereleases dummy) add_version_test(old_version_file_samemajor dummy) add_version_test(old_header check_header) add_version_test(old_header_abspath check_header) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt b/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt deleted file mode 100644 index e498fce6..00000000 --- a/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt +++ /dev/null @@ -1,189 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) - -project(old_version_file_prereleases) - -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules) -include(ECMSetupVersion) - -ecm_setup_version(2.3.4 - VARIABLE_PREFIX Foo - PACKAGE_VERSION_FILE FooVersion.cmake - COMPATIBILITY SameMajorVersionWithPrereleases - FIRST_PRERELEASE_VERSION 90 -) - -include(../../test_helpers.cmake) -include(../version_helpers.cmake) - -macro(find_foo version) - test_version_file("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake" "${version}") - assert_var_str_value(PACKAGE_VERSION "2.3.4") -endmacro() - -standard_version_var_checks(Foo 2.3.4) - -# too old - fails -find_foo("3.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for wrong major version - fails -find_foo("2.90.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for correct major version - succeeds -find_foo("1.90") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for correct major version - succeeds -find_foo("1.90.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for correct major version - succeeds -find_foo("1.95.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, more recent - succeeds -find_foo("2.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version - succeeds -find_foo("2") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, but too old - fails -find_foo("2.4.4") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# exact - succeeds -find_foo("2.3.4") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) - - - - -ecm_setup_version(2.90.0 - VARIABLE_PREFIX Foo3Prerelease - PACKAGE_VERSION_FILE Foo3PrereleaseVersion.cmake - COMPATIBILITY SameMajorVersionWithPrereleases - FIRST_PRERELEASE_VERSION 90 -) - -macro(find_foo version) - test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3PrereleaseVersion.cmake" "${version}") - assert_var_str_value(PACKAGE_VERSION "2.90.0") -endmacro() - -standard_version_var_checks(Foo3Prerelease 2.90.0) - -# too old - fails -find_foo("3.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# too old - fails -find_foo("2.90.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, but don't want a prerelease - fails -find_foo("3") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2.89.9") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# exact version - succeeds -find_foo("2.90.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) - - - - -ecm_setup_version(2.93.4 - VARIABLE_PREFIX Foo3Prerelease2 - PACKAGE_VERSION_FILE Foo3Prerelease2Version.cmake - COMPATIBILITY SameMajorVersionWithPrereleases - FIRST_PRERELEASE_VERSION 90 -) - -macro(find_foo version) - test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3Prerelease2Version.cmake" "${version}") - assert_var_str_value(PACKAGE_VERSION "2.93.4") -endmacro() - -standard_version_var_checks(Foo3Prerelease2 2.93.4) - -# too old - fails -find_foo("3.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# too old - fails -find_foo("2.94.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, but don't want a prerelease - fails -find_foo("3") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2.89.9") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version - succeeds -find_foo("2.90.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# exact version - succeeds -find_foo("2.93.4") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) - -add_executable(dummy main.c) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c b/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c deleted file mode 100644 index c13815ce..00000000 --- a/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() -{ - return 0; -} diff --git a/tests/test_helpers.cmake b/tests/test_helpers.cmake index 236a1868..73be343e 100644 --- a/tests/test_helpers.cmake +++ b/tests/test_helpers.cmake @@ -38,9 +38,9 @@ macro(assert_var_bool_value varname value) assert_var_defined(${varname}) endif() if(${value} AND NOT ${varname}) - message(SEND_ERROR "${varname} was FALSE") + message(FATAL_ERROR "${varname} was FALSE") elseif(${varname} AND NOT ${value}) - message(SEND_ERROR "${varname} was TRUE") + message(FATAL_ERROR "${varname} was TRUE") endif() endmacro() -- cgit v1.2.1 From fc56bfbb62a9438960fec9e5960fde5f3e5c1a46 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sun, 15 Feb 2015 21:45:34 +0100 Subject: Extend ecm_generate_headers macro to also support CamelCase.h headers REVIEW: 122317 Thanks alexmerry and dvratil for review --- tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h | 0 tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h | 0 tests/ECMGenerateHeadersTest/run_test.cmake.config | 45 ++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h create mode 100644 tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h (limited to 'tests') diff --git a/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h new file mode 100644 index 00000000..e69de29b diff --git a/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h new file mode 100644 index 00000000..e69de29b diff --git a/tests/ECMGenerateHeadersTest/run_test.cmake.config b/tests/ECMGenerateHeadersTest/run_test.cmake.config index 0a2425fe..1db623b7 100644 --- a/tests/ECMGenerateHeadersTest/run_test.cmake.config +++ b/tests/ECMGenerateHeadersTest/run_test.cmake.config @@ -244,4 +244,49 @@ 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}) + + # vim:ft=cmake -- cgit v1.2.1 From 19353c9857d1e26c6508c2fc7dd530e6ee0ef316 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 14 Mar 2015 12:44:49 +0000 Subject: Warn about icon filenames with leading characters. Through a quirk of implementation, old-style icon filenames are accepted by the new-style ecm_install_icons function. It's too late to change it now, as that would break existing projects, but we can warn about it. REVIEW: 122941 --- tests/ECMInstallIconsTest/16-apps-cmake.png | Bin 233 -> 0 bytes tests/ECMInstallIconsTest/CMakeLists.txt | 15 ++++++++------- .../hicolor/16x16/actions/old-style-name.png | Bin 0 -> 233 bytes .../ECMInstallIconsTest/hi16-actions-old-style-name.png | Bin 0 -> 233 bytes tests/ECMInstallIconsTest/subdir/16-apps-cmake.png | Bin 0 -> 233 bytes 5 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 tests/ECMInstallIconsTest/16-apps-cmake.png create mode 100644 tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png create mode 100644 tests/ECMInstallIconsTest/hi16-actions-old-style-name.png create mode 100644 tests/ECMInstallIconsTest/subdir/16-apps-cmake.png (limited to 'tests') diff --git a/tests/ECMInstallIconsTest/16-apps-cmake.png b/tests/ECMInstallIconsTest/16-apps-cmake.png deleted file mode 100644 index ed9a1181..00000000 Binary files a/tests/ECMInstallIconsTest/16-apps-cmake.png and /dev/null differ diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt index 85f2d9f5..7fe4ca35 100644 --- a/tests/ECMInstallIconsTest/CMakeLists.txt +++ b/tests/ECMInstallIconsTest/CMakeLists.txt @@ -20,7 +20,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 +36,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 +53,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 +70,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,9 +87,10 @@ 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 ) diff --git a/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png new file mode 100644 index 00000000..ed9a1181 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png differ -- cgit v1.2.1 From 1b636b43d2bf4dca0332a2e2b36affa67fbe1e0b Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 11 May 2015 13:56:28 +0100 Subject: Add unit tests for ECMAddTests module. REVIEW: 123722 --- tests/CMakeLists.txt | 1 + tests/ECMAddTests/CMakeLists.txt | 49 +++++++++ tests/ECMAddTests/check_files.cmake | 15 +++ tests/ECMAddTests/multi_tests/CMakeLists.txt | 142 ++++++++++++++++++++++++++ tests/ECMAddTests/multi_tests/test1.cpp | 8 ++ tests/ECMAddTests/multi_tests/test2.cpp | 8 ++ tests/ECMAddTests/multi_tests/test3.cpp | 8 ++ tests/ECMAddTests/multi_tests/test4.cpp | 8 ++ tests/ECMAddTests/multi_tests/test5.cpp | 8 ++ tests/ECMAddTests/multi_tests/test6.cpp | 8 ++ tests/ECMAddTests/multi_tests/test7.cpp | 8 ++ tests/ECMAddTests/multi_tests/test8.cpp | 8 ++ tests/ECMAddTests/multi_tests/test9.cpp | 8 ++ tests/ECMAddTests/single_tests/CMakeLists.txt | 122 ++++++++++++++++++++++ tests/ECMAddTests/single_tests/test1.cpp | 8 ++ tests/ECMAddTests/single_tests/test2.cpp | 8 ++ tests/ECMAddTests/single_tests/test3.cpp | 8 ++ tests/ECMAddTests/single_tests/test4.cpp | 8 ++ tests/ECMAddTests/single_tests/test5.cpp | 8 ++ tests/ECMAddTests/single_tests/test6.cpp | 8 ++ tests/ECMAddTests/single_tests/test6body.cpp | 7 ++ tests/ECMAddTests/testhelper.cpp | 8 ++ tests/ECMAddTests/testhelper.h | 1 + 23 files changed, 465 insertions(+) create mode 100644 tests/ECMAddTests/CMakeLists.txt create mode 100644 tests/ECMAddTests/check_files.cmake create mode 100644 tests/ECMAddTests/multi_tests/CMakeLists.txt create mode 100644 tests/ECMAddTests/multi_tests/test1.cpp create mode 100644 tests/ECMAddTests/multi_tests/test2.cpp create mode 100644 tests/ECMAddTests/multi_tests/test3.cpp create mode 100644 tests/ECMAddTests/multi_tests/test4.cpp create mode 100644 tests/ECMAddTests/multi_tests/test5.cpp create mode 100644 tests/ECMAddTests/multi_tests/test6.cpp create mode 100644 tests/ECMAddTests/multi_tests/test7.cpp create mode 100644 tests/ECMAddTests/multi_tests/test8.cpp create mode 100644 tests/ECMAddTests/multi_tests/test9.cpp create mode 100644 tests/ECMAddTests/single_tests/CMakeLists.txt create mode 100644 tests/ECMAddTests/single_tests/test1.cpp create mode 100644 tests/ECMAddTests/single_tests/test2.cpp create mode 100644 tests/ECMAddTests/single_tests/test3.cpp create mode 100644 tests/ECMAddTests/single_tests/test4.cpp create mode 100644 tests/ECMAddTests/single_tests/test5.cpp create mode 100644 tests/ECMAddTests/single_tests/test6.cpp create mode 100644 tests/ECMAddTests/single_tests/test6body.cpp create mode 100644 tests/ECMAddTests/testhelper.cpp create mode 100644 tests/ECMAddTests/testhelper.h (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc3e5ce8..7960154a 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) 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..ca434773 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -0,0 +1,142 @@ +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" + "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test8.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" + ) + +ecm_add_tests( + test1.cpp + test2.cpp + test3.cpp + LINK_LIBRARIES testhelper + ) +# 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() + + +ecm_add_tests( + test8.cpp + test9.cpp + LINK_LIBRARIES testhelper + NAME_PREFIX p_ + GUI + ) +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 +#include + +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); -- cgit v1.2.1 From 0c224194ea7f12eaed32af746fc9138537f1919c Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 11 May 2015 13:56:28 +0100 Subject: Add PROPERTIES argument to ecm_add_test and ecm_add_tests. This is particularly useful with ecm_add_tests, where you may want to force a suite of tests to run in serial, or alter the timeout for multiple tests at once. BUG: 345797 REVIEW: 123722 --- tests/ECMAddTests/CMakeLists.txt | 3 + tests/ECMAddTests/multi_tests/CMakeLists.txt | 96 +++++++++++++++++++++------ tests/ECMAddTests/multi_tests/test10.cpp | 8 +++ tests/ECMAddTests/multi_tests/test11.cpp | 8 +++ tests/ECMAddTests/single_tests/CMakeLists.txt | 39 ++++++++--- tests/ECMAddTests/single_tests/test7.cpp | 8 +++ 6 files changed, 134 insertions(+), 28 deletions(-) create mode 100644 tests/ECMAddTests/multi_tests/test10.cpp create mode 100644 tests/ECMAddTests/multi_tests/test11.cpp create mode 100644 tests/ECMAddTests/single_tests/test7.cpp (limited to 'tests') diff --git a/tests/ECMAddTests/CMakeLists.txt b/tests/ECMAddTests/CMakeLists.txt index e77b33f9..b31934d4 100644 --- a/tests/ECMAddTests/CMakeLists.txt +++ b/tests/ECMAddTests/CMakeLists.txt @@ -34,6 +34,7 @@ add_check(single_tests test4.txt test5.txt test6.txt + test7.txt ) add_check(multi_tests test1.txt @@ -45,5 +46,7 @@ add_check(multi_tests test7.txt test8.txt test9.txt + test10.txt + test11.txt ) diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt index ca434773..bad625b5 100644 --- a/tests/ECMAddTests/multi_tests/CMakeLists.txt +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -22,6 +22,8 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" "${CMAKE_CURRENT_BINARY_DIR}/test8.txt" "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test10.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test11.txt" ) ecm_add_tests( @@ -30,14 +32,6 @@ ecm_add_tests( test3.cpp LINK_LIBRARIES testhelper ) -# 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") @@ -46,6 +40,9 @@ 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() +# existence check +get_property(_dummy TEST test1 PROPERTY TIMEOUT) + 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") @@ -54,6 +51,17 @@ 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() +get_property(_dummy TEST test2 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() +get_property(_dummy TEST test3 PROPERTY TIMEOUT) ecm_add_tests( @@ -62,10 +70,6 @@ ecm_add_tests( 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") @@ -74,6 +78,8 @@ 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(_dummy TEST pref_test4 PROPERTY TIMEOUT) + 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") @@ -82,6 +88,7 @@ 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() +get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) ecm_add_tests( @@ -90,10 +97,6 @@ ecm_add_tests( 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") @@ -102,6 +105,8 @@ 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(_dummy TEST test6 PROPERTY TIMEOUT) + 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") @@ -110,6 +115,7 @@ 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() +get_property(_dummy TEST test7 PROPERTY TIMEOUT) ecm_add_tests( @@ -118,11 +124,9 @@ ecm_add_tests( LINK_LIBRARIES testhelper NAME_PREFIX p_ GUI + PROPERTIES + LABELS "somelabel" ) -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") @@ -131,6 +135,11 @@ 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(_labels TEST p_test8 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "p_test8 LABELS property was \"${_labels}\", expected \"somelabel\"") +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") @@ -139,4 +148,51 @@ 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() +get_property(_labels TEST p_test9 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "p_test9 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() + + +ecm_add_tests( + test10.cpp + test11.cpp + LINK_LIBRARIES testhelper + PROPERTIES + LABELS "somelabel" + RUN_SERIAL TRUE + ) +get_property(_is_win32 TARGET test10 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test10 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test10 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test10 is an OS/X bundle when it should not be") +endif() +get_property(_labels TEST test10 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "test10 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() +get_property(_run_serial TEST test10 PROPERTY RUN_SERIAL) +if (NOT _run_serial) + message(FATAL_ERROR "test10 LABELS property was \"${_run_serial}\", expected TRUE") +endif() + +get_property(_is_win32 TARGET test11 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test11 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test11 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test11 is an OS/X bundle when it should not be") +endif() +get_property(_labels TEST test11 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "test11 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() +get_property(_run_serial TEST test11 PROPERTY RUN_SERIAL) +if (NOT _run_serial) + message(FATAL_ERROR "test11 LABELS property was \"${_run_serial}\", expected TRUE") +endif() diff --git a/tests/ECMAddTests/multi_tests/test10.cpp b/tests/ECMAddTests/multi_tests/test10.cpp new file mode 100644 index 00000000..a34a39df --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test10.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test10.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test11.cpp b/tests/ECMAddTests/multi_tests/test11.cpp new file mode 100644 index 00000000..82641bbc --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test11.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test11.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/CMakeLists.txt b/tests/ECMAddTests/single_tests/CMakeLists.txt index 6af3857b..de1ae6f6 100644 --- a/tests/ECMAddTests/single_tests/CMakeLists.txt +++ b/tests/ECMAddTests/single_tests/CMakeLists.txt @@ -19,13 +19,12 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test4.txt" "${CMAKE_CURRENT_BINARY_DIR}/test5.txt" "${CMAKE_CURRENT_BINARY_DIR}/test6.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test7.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) @@ -42,7 +41,6 @@ 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) @@ -58,7 +56,6 @@ 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) @@ -74,7 +71,6 @@ 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) @@ -91,9 +87,10 @@ ecm_add_test(test5.cpp TEST_NAME combined_test NAME_PREFIX another_prefix_ GUI + PROPERTIES + LABELS "lab" + RUN_SERIAL TRUE ) -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") @@ -102,13 +99,20 @@ 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() +get_property(_labels TEST another_prefix_combined_test PROPERTY LABELS) +if (NOT _labels STREQUAL "lab") + message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_labels}\", expected \"lab\"") +endif() +get_property(_run_serial TEST another_prefix_combined_test PROPERTY RUN_SERIAL) +if (NOT _run_serial) + message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_run_serial}\", expected TRUE") +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) @@ -120,3 +124,22 @@ if (_is_bundle) endif() +ecm_add_test(test7.cpp + LINK_LIBRARIES testhelper + PROPERTIES + LABELS "somelabel" + ) +get_property(_dummy TEST test7 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test7 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test7 is an OS/X bundle when it should not be") +endif() +get_property(_labels TEST test7 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "test7 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() + diff --git a/tests/ECMAddTests/single_tests/test7.cpp b/tests/ECMAddTests/single_tests/test7.cpp new file mode 100644 index 00000000..069859e7 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test7.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test7.txt"); + return 0; +} + -- cgit v1.2.1 From 70b13693478b296b8a3cd1654baa8013434358c5 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 16 May 2015 14:06:34 +0100 Subject: Revert "Add PROPERTIES argument to ecm_add_test and ecm_add_tests." This reverts commit 0c224194ea7f12eaed32af746fc9138537f1919c. Stephen Kelly pointed out that this is probably not the best approach to the problem, and runs counter to the direction KDE's CMake code has been going (splitting functions up and using CMake built-ins where possible). I have a better solution in mind, which I'll post a review for later. CCMAIL: kde-buildsystem@kde.org CCBUG: 345797 --- tests/ECMAddTests/CMakeLists.txt | 3 - tests/ECMAddTests/multi_tests/CMakeLists.txt | 96 ++++++--------------------- tests/ECMAddTests/multi_tests/test10.cpp | 8 --- tests/ECMAddTests/multi_tests/test11.cpp | 8 --- tests/ECMAddTests/single_tests/CMakeLists.txt | 39 +++-------- tests/ECMAddTests/single_tests/test7.cpp | 8 --- 6 files changed, 28 insertions(+), 134 deletions(-) delete mode 100644 tests/ECMAddTests/multi_tests/test10.cpp delete mode 100644 tests/ECMAddTests/multi_tests/test11.cpp delete mode 100644 tests/ECMAddTests/single_tests/test7.cpp (limited to 'tests') diff --git a/tests/ECMAddTests/CMakeLists.txt b/tests/ECMAddTests/CMakeLists.txt index b31934d4..e77b33f9 100644 --- a/tests/ECMAddTests/CMakeLists.txt +++ b/tests/ECMAddTests/CMakeLists.txt @@ -34,7 +34,6 @@ add_check(single_tests test4.txt test5.txt test6.txt - test7.txt ) add_check(multi_tests test1.txt @@ -46,7 +45,5 @@ add_check(multi_tests test7.txt test8.txt test9.txt - test10.txt - test11.txt ) diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt index bad625b5..ca434773 100644 --- a/tests/ECMAddTests/multi_tests/CMakeLists.txt +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -22,8 +22,6 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" "${CMAKE_CURRENT_BINARY_DIR}/test8.txt" "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" - "${CMAKE_CURRENT_BINARY_DIR}/test10.txt" - "${CMAKE_CURRENT_BINARY_DIR}/test11.txt" ) ecm_add_tests( @@ -32,6 +30,14 @@ ecm_add_tests( test3.cpp LINK_LIBRARIES testhelper ) +# 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") @@ -40,9 +46,6 @@ 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() -# existence check -get_property(_dummy TEST test1 PROPERTY TIMEOUT) - 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") @@ -51,17 +54,6 @@ 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() -get_property(_dummy TEST test2 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() -get_property(_dummy TEST test3 PROPERTY TIMEOUT) ecm_add_tests( @@ -70,6 +62,10 @@ ecm_add_tests( 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") @@ -78,8 +74,6 @@ 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(_dummy TEST pref_test4 PROPERTY TIMEOUT) - 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") @@ -88,7 +82,6 @@ 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() -get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) ecm_add_tests( @@ -97,6 +90,10 @@ ecm_add_tests( 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") @@ -105,8 +102,6 @@ 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(_dummy TEST test6 PROPERTY TIMEOUT) - 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") @@ -115,7 +110,6 @@ 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() -get_property(_dummy TEST test7 PROPERTY TIMEOUT) ecm_add_tests( @@ -124,9 +118,11 @@ ecm_add_tests( LINK_LIBRARIES testhelper NAME_PREFIX p_ GUI - PROPERTIES - LABELS "somelabel" ) +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") @@ -135,11 +131,6 @@ 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(_labels TEST p_test8 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "p_test8 LABELS property was \"${_labels}\", expected \"somelabel\"") -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") @@ -148,51 +139,4 @@ 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() -get_property(_labels TEST p_test9 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "p_test9 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() - - -ecm_add_tests( - test10.cpp - test11.cpp - LINK_LIBRARIES testhelper - PROPERTIES - LABELS "somelabel" - RUN_SERIAL TRUE - ) -get_property(_is_win32 TARGET test10 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test10 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test10 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test10 is an OS/X bundle when it should not be") -endif() -get_property(_labels TEST test10 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "test10 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() -get_property(_run_serial TEST test10 PROPERTY RUN_SERIAL) -if (NOT _run_serial) - message(FATAL_ERROR "test10 LABELS property was \"${_run_serial}\", expected TRUE") -endif() - -get_property(_is_win32 TARGET test11 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test11 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test11 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test11 is an OS/X bundle when it should not be") -endif() -get_property(_labels TEST test11 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "test11 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() -get_property(_run_serial TEST test11 PROPERTY RUN_SERIAL) -if (NOT _run_serial) - message(FATAL_ERROR "test11 LABELS property was \"${_run_serial}\", expected TRUE") -endif() diff --git a/tests/ECMAddTests/multi_tests/test10.cpp b/tests/ECMAddTests/multi_tests/test10.cpp deleted file mode 100644 index a34a39df..00000000 --- a/tests/ECMAddTests/multi_tests/test10.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "testhelper.h" - -int main() -{ - make_test_file("test10.txt"); - return 0; -} - diff --git a/tests/ECMAddTests/multi_tests/test11.cpp b/tests/ECMAddTests/multi_tests/test11.cpp deleted file mode 100644 index 82641bbc..00000000 --- a/tests/ECMAddTests/multi_tests/test11.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "testhelper.h" - -int main() -{ - make_test_file("test11.txt"); - return 0; -} - diff --git a/tests/ECMAddTests/single_tests/CMakeLists.txt b/tests/ECMAddTests/single_tests/CMakeLists.txt index de1ae6f6..6af3857b 100644 --- a/tests/ECMAddTests/single_tests/CMakeLists.txt +++ b/tests/ECMAddTests/single_tests/CMakeLists.txt @@ -19,12 +19,13 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test4.txt" "${CMAKE_CURRENT_BINARY_DIR}/test5.txt" "${CMAKE_CURRENT_BINARY_DIR}/test6.txt" - "${CMAKE_CURRENT_BINARY_DIR}/test7.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) @@ -41,6 +42,7 @@ 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) @@ -56,6 +58,7 @@ 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) @@ -71,6 +74,7 @@ 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) @@ -87,10 +91,9 @@ ecm_add_test(test5.cpp TEST_NAME combined_test NAME_PREFIX another_prefix_ GUI - PROPERTIES - LABELS "lab" - RUN_SERIAL TRUE ) +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") @@ -99,20 +102,13 @@ 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() -get_property(_labels TEST another_prefix_combined_test PROPERTY LABELS) -if (NOT _labels STREQUAL "lab") - message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_labels}\", expected \"lab\"") -endif() -get_property(_run_serial TEST another_prefix_combined_test PROPERTY RUN_SERIAL) -if (NOT _run_serial) - message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_run_serial}\", expected TRUE") -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) @@ -124,22 +120,3 @@ if (_is_bundle) endif() -ecm_add_test(test7.cpp - LINK_LIBRARIES testhelper - PROPERTIES - LABELS "somelabel" - ) -get_property(_dummy TEST test7 PROPERTY TIMEOUT) -get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test7 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test7 is an OS/X bundle when it should not be") -endif() -get_property(_labels TEST test7 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "test7 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() - diff --git a/tests/ECMAddTests/single_tests/test7.cpp b/tests/ECMAddTests/single_tests/test7.cpp deleted file mode 100644 index 069859e7..00000000 --- a/tests/ECMAddTests/single_tests/test7.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "testhelper.h" - -int main() -{ - make_test_file("test7.txt"); - return 0; -} - -- cgit v1.2.1 From be390dcc4d77d7faa95d040b1a346ac3c0405eac Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 18 May 2015 19:12:06 +0100 Subject: Add arguments to ecm_add_tests for listing added tests. This makes it convenient to make further modifications to the tests, such as setting properties on either the tests or the targets. CHANGELOG: New arguments for ecm_add_tests(). BUG: 345797 REVIEW: 123841 --- tests/ECMAddTests/multi_tests/CMakeLists.txt | 13 +++++++++++++ tests/test_helpers.cmake | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'tests') diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt index ca434773..0133c7d6 100644 --- a/tests/ECMAddTests/multi_tests/CMakeLists.txt +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -10,6 +10,7 @@ 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 @@ -24,12 +25,18 @@ file(REMOVE "${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) @@ -112,13 +119,19 @@ if (NOT _is_bundle) 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) 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() + -- cgit v1.2.1 From ef88a6683a2578679b3c98396a9ee3001db69541 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 31 May 2015 21:38:50 +0200 Subject: Fix test on OSX, no bundle expected here. CI said: Linking C executable dummy.app/Contents/MacOS/dummy Built target dummy Could not find path to executable, perhaps it was not built: dummy REVIEW: 123969 --- tests/ExecuteKDEModules/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') 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}) -- cgit v1.2.1 From 9bffa7a202cad3a29103f3e9a8b50b9a61277310 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 29 Jul 2015 22:46:44 +0200 Subject: Add macro to generate logging category declarations for Qt5. This makes life a bit easier for developers who use the categorised logging in Qt5 in the common case - rather than creating two new files, and remembering to put in the #ifdef for the default verbosity settings in Qt 5.4, they can just add a couple of lines to their CMakeLists.txt. REVIEW: 124595 --- tests/CMakeLists.txt | 3 + .../ECMQtDeclareLoggingCategoryTest/CMakeLists.txt | 42 +++++++++++ tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp | 83 ++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt create mode 100644 tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7960154a..8a75ae61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -85,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) 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..a06614a1 --- /dev/null +++ b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp @@ -0,0 +1,83 @@ +#include + +#include "log1.h" +#include "log2.h" +#include "log3.h" + +#include + +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; +} -- cgit v1.2.1 From 8e20caf11dbabdf191415589e99ea1b773caedd0 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 19 Aug 2015 22:05:22 +0100 Subject: Add a license to one of the C++ test files. --- tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp index a06614a1..4abcd527 100644 --- a/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp +++ b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp @@ -1,3 +1,28 @@ +/* + * 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 #include "log1.h" -- cgit v1.2.1 From a1e60b8e6386f3b674d31b6a5e76214cf98a2bd8 Mon Sep 17 00:00:00 2001 From: Patrick Spendrin Date: Thu, 20 Aug 2015 21:44:42 +0200 Subject: correct the test name, so that we don't have a duplicate ECMGenerateHeaders test --- tests/ECMGeneratePkgConfigFile/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') 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") -- cgit v1.2.1 From 8ef3f474e3a6def47dce36b54fbdce2d98c79342 Mon Sep 17 00:00:00 2001 From: Patrick Spendrin Date: Thu, 20 Aug 2015 21:46:20 +0200 Subject: add COMMON_HEADER option and multiple header functionality This adds a new keyword COMMON_HEADER which generates a new header containing all other headers. Also it is possible now to have multiple dummy headers per header file. It is assumed that the first header is the existing one. REVIEW: 124847 --- tests/ECMGenerateHeadersTest/CommonHeader | 4 ++ tests/ECMGenerateHeadersTest/headtest4.h | 0 tests/ECMGenerateHeadersTest/run_test.cmake.config | 65 ++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 tests/ECMGenerateHeadersTest/CommonHeader create mode 100644 tests/ECMGenerateHeadersTest/headtest4.h (limited to 'tests') 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 diff --git a/tests/ECMGenerateHeadersTest/run_test.cmake.config b/tests/ECMGenerateHeadersTest/run_test.cmake.config index 1db623b7..a9027dbc 100644 --- a/tests/ECMGenerateHeadersTest/run_test.cmake.config +++ b/tests/ECMGenerateHeadersTest/run_test.cmake.config @@ -288,5 +288,70 @@ check_files(GENERATED ${expfiles} 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 -- cgit v1.2.1 From fb7b8eea7d91772f989d5b060c86df20f2ebdb66 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 14 Oct 2015 12:10:31 +0100 Subject: Fix ECMInstallIconsTest. ECMInstallIcons now updates the theme cache if gtk-update-icon-cache is available, producing files the test hadn't been expecting.. Updating the test revealed that the old-style ecm_install_icons call only updated the hicolor cache, and not any of the other themes. REVIEW: 125631 --- tests/ECMInstallIconsTest/CMakeLists.txt | 7 +++++++ tests/ECMInstallIconsTest/check_tree.cmake.in | 7 +++++++ .../badly-named-files-test/hicolor/icon-theme.cache | Bin 0 -> 124 bytes .../expected-tree/lang-test/hicolor/icon-theme.cache | Bin 0 -> 548 bytes .../multi-file-test/hicolor/icon-theme.cache | Bin 0 -> 472 bytes .../single-file-test/hicolor/icon-theme.cache | Bin 0 -> 120 bytes .../themed-lang-test/oxygen/icon-theme.cache | Bin 0 -> 548 bytes .../themed-test/theme-name-2/icon-theme.cache | Bin 0 -> 472 bytes .../expected-tree/v1-icons/crystalsvg/icon-theme.cache | Bin 0 -> 164 bytes .../expected-tree/v1-icons/hicolor/icon-theme.cache | Bin 0 -> 452 bytes 10 files changed, 14 insertions(+) create mode 100644 tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache (limited to 'tests') diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt index 7fe4ca35..738cba91 100644 --- a/tests/ECMInstallIconsTest/CMakeLists.txt +++ b/tests/ECMInstallIconsTest/CMakeLists.txt @@ -94,5 +94,12 @@ ecm_install_icons( 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/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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache 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 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache differ -- cgit v1.2.1 From 009c480413910e8c1a18f4d1420f4a517ea606e6 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 14 Oct 2015 12:18:40 +0100 Subject: Make sure we load translations on the main thread. BUG: 346188 REVIEW: 123726 --- tests/CMakeLists.txt | 4 +- tests/ECMPoQmToolsTest/CMakeLists.txt | 32 +++++++-- tests/ECMPoQmToolsTest/check.cmake.in | 81 ++++++++++++++++++++++ tests/ECMPoQmToolsTest/check_conf.cmake.in | 2 + tests/ECMPoQmToolsTest/check_tree.cmake.in | 61 ---------------- tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po | 22 ++++++ tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ++++++ tests/ECMPoQmToolsTest/tr_test.cpp | 16 +++++ tests/ECMPoQmToolsTest/tr_thread_test.cpp | 68 ++++++++++++++++++ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 12 ++++ 10 files changed, 252 insertions(+), 68 deletions(-) create mode 100644 tests/ECMPoQmToolsTest/check.cmake.in create mode 100644 tests/ECMPoQmToolsTest/check_conf.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/check_tree.cmake.in create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test.cpp create mode 100644 tests/ECMPoQmToolsTest/tr_thread_test.cpp create mode 100644 tests/ECMPoQmToolsTest/tr_thread_test_module.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a75ae61..9e6de12f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,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/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index 15351d2f..e08a2b8c 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -9,9 +9,14 @@ 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) + +unset(QMLOADER_FILES) +ecm_create_qm_loader(QMLOADER_FILES catalog) +assert_var_defined(QMLOADER_FILES) + +# These will be used to test the above-generated loader +ecm_install_po_files_as_qm(tr_test-po) # Should create a process-and-install.qm file and install it ecm_process_po_files_as_qm(fr ALL @@ -39,5 +44,22 @@ ecm_install_po_files_as_qm(po-custom-dir1) 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) +find_package(Qt5Core CONFIG REQUIRED) + +add_executable(tr_test tr_test.cpp ${QMLOADER_FILES}) +target_link_libraries(tr_test PRIVATE Qt5::Core) + +add_library(tr_thread_module MODULE tr_thread_test_module.cpp ${QMLOADER_FILES}) +target_link_libraries(tr_thread_module PRIVATE Qt5::Core) + +add_executable(tr_thread_test tr_thread_test.cpp) +set_target_properties(tr_thread_test PROPERTIES AUTOMOC ON) +target_include_directories(tr_thread_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") +target_compile_definitions(tr_thread_test PRIVATE "MODULE_PATH=\"$\"") +target_link_libraries(tr_thread_test PRIVATE Qt5::Core) + +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.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in new file mode 100644 index 00000000..2f0cc205 --- /dev/null +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -0,0 +1,81 @@ +set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") +set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +include("${BINARY_DIR}/check_conf.cmake") + +set(fail OFF) + +macro(mark_failed msg) + message(WARNING "FAIL: ${msg}") + set(fail ON) +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}/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/en_GB/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" + "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" +) +file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +list(SORT exp_files) +list(SORT actual_files) + +if(NOT exp_files STREQUAL actual_files) + foreach(f ${exp_files}) + list(FIND actual_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was expected, but not found") + set(fail ON) + endif() + endforeach() + foreach(f ${actual_files}) + list(FIND exp_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was found, but not expected") + 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_en_GB "british english text:british english plural form 5") + # no french translation provided -> english fallback + set(exp_output_fr "${exp_output_en}") + foreach(exec TR_TEST TR_THREAD_TEST) + foreach(lang en en_GB fr) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" + LC_ALL=${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) + message(FATAL_ERROR "Test failed!") +endif() diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in new file mode 100644 index 00000000..0bbab1d9 --- /dev/null +++ b/tests/ECMPoQmToolsTest/check_conf.cmake.in @@ -0,0 +1,2 @@ +set(TR_TEST_EXEC "$") +set(TR_THREAD_TEST_EXEC "$") diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check_tree.cmake.in deleted file mode 100644 index 9f4f7c0d..00000000 --- a/tests/ECMPoQmToolsTest/check_tree.cmake.in +++ /dev/null @@ -1,61 +0,0 @@ -set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") -set(QMLOADER_PATH "@QMLOADER_PATH@") - -set(fail OFF) - -macro(mark_failed msg) - message(WARNING "FAIL: ${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) - 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" - "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" - "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" -) -file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") -list(SORT exp_files) -list(SORT actual_files) - -if(NOT exp_files STREQUAL actual_files) - foreach(f ${exp_files}) - list(FIND actual_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was expected, but not found") - set(fail ON) - endif() - endforeach() - foreach(f ${actual_files}) - list(FIND exp_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was found, but not expected") - set(fail ON) - endif() - endforeach() -endif() - -if (fail) - message(FATAL_ERROR "Test failed!") -endif() 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-po/en_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po new file mode 100644 index 00000000..ec5ad857 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/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_GB\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "british english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "british english singular form %n" +msgstr[1] "british english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp new file mode 100644 index 00000000..be5d3427 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -0,0 +1,16 @@ +#include +#include + +#include + +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/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp new file mode 100644 index 00000000..3ed30ee1 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_thread_test.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +class Thread : public QThread +{ + Q_OBJECT + + QLibrary *m_lib; + +public: + Thread() + : m_lib(0) + {} + ~Thread() + { + delete m_lib; + } + +Q_SIGNALS: + void libraryLoaded(); + +public Q_SLOTS: + void printStrings() + { + // NB: this will run on the *main* event loop. + QFunctionPointer print_strings = m_lib->resolve("print_strings"); + if (print_strings) { + print_strings(); + } else { + qFatal("Could not resolve print_strings: %s", m_lib->errorString().toUtf8().data()); + } + + QCoreApplication::instance()->quit(); + } +protected: + void run() + { + m_lib = new QLibrary(MODULE_PATH); + + if (!m_lib->load()) { + qFatal("Could not load module: %s", m_lib->errorString().toUtf8().data()); + } + + // Queue a call to printStrings() on the main event loop (giving the + // translations a chance to be loaded). + QMetaObject::invokeMethod(this, "printStrings", Qt::QueuedConnection); + } +}; + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + Thread thread; + + // Start the thread *after* QCoreApplication is started (otherwise the + // plugin's startup function won't be run on the Thread, and we won't test + // what we wanted to test). + QMetaObject::invokeMethod(&thread, "start", Qt::QueuedConnection); + + app.exec(); + + return 0; +} + +#include "tr_thread_test.moc" diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp new file mode 100644 index 00000000..b9000ffa --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp @@ -0,0 +1,12 @@ +#include +#include + +#include + +extern "C" Q_DECL_EXPORT void print_strings() +{ + QTextStream output(stdout); + + output << QCoreApplication::translate("testcontext", "test string") << ":"; + output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; +} -- cgit v1.2.1 From 634a0a2d3d7ba1bec2bae846acf0faf6184f4c71 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 10:30:14 +0000 Subject: Add license to tests. --- tests/ECMPoQmToolsTest/tr_test.cpp | 27 ++++++++++++++++++++++++ tests/ECMPoQmToolsTest/tr_thread_test.cpp | 27 ++++++++++++++++++++++++ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 27 ++++++++++++++++++++++++ 3 files changed, 81 insertions(+) (limited to 'tests') diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp index be5d3427..6536b60d 100644 --- a/tests/ECMPoQmToolsTest/tr_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -1,3 +1,30 @@ +/* + * Copyright 2015 Alex Merry + * + * 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 #include diff --git a/tests/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp index 3ed30ee1..e128dc9d 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test.cpp @@ -1,3 +1,30 @@ +/* + * Copyright 2015 Alex Merry + * + * 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 #include #include diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp index b9000ffa..d13539e2 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp @@ -1,3 +1,30 @@ +/* + * Copyright 2015 Alex Merry + * + * 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 #include -- cgit v1.2.1 From 0496f8ae020c497b5f65234063150781d023f8ba Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 17:13:00 +0000 Subject: Change ecm_create_po_loader test language to German. This is easier to distinguish from "english" in the test output than "british english". --- tests/ECMPoQmToolsTest/check.cmake.in | 6 +++--- tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po | 22 ++++++++++++++++++++++ tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ---------------------- 3 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po (limited to 'tests') diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 2f0cc205..8089db6e 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -23,7 +23,7 @@ set(exp_files "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/en_GB/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" @@ -55,11 +55,11 @@ 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_en_GB "british english text:british 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_THREAD_TEST) - foreach(lang en en_GB fr) + foreach(lang en de fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" LC_ALL=${lang} "${${exec}_EXEC}" 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_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po deleted file mode 100644 index ec5ad857..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -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_GB\n" -"X-Qt-Contexts: true\n" - -#: main.cpp:12 -msgctxt "testcontext|" -msgid "test string" -msgstr "british english text" - -#: main.cpp:13 -#, qt-format -#| msgid "test plural" -msgctxt "testcontext|" -msgid "test plural %n" -msgid_plural "test plural %n" -msgstr[0] "british english singular form %n" -msgstr[1] "british english plural form %n" -- cgit v1.2.1 From 39484722101730d4f1a4bccbc5467c0eb2cc0f6f Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 17:27:45 +0000 Subject: Fix ECMPoQmToolsTest. LANGUAGE has higher priority than LC_ALL. --- tests/ECMPoQmToolsTest/check.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 8089db6e..6e6d46fe 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -62,7 +62,7 @@ if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") foreach(lang en de fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" - LC_ALL=${lang} "${${exec}_EXEC}" + LANGUAGE=${lang} "${${exec}_EXEC}" OUTPUT_VARIABLE output ) string(STRIP "${output}" stripped_output) -- cgit v1.2.1 From 21629f651a6a5d9d977be03fd9f98417c4fa27ae Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 12:00:44 +0000 Subject: Warn instead of error if ecm_install_icons finds no icons. The V1 syntax of ecm_install_icons searched for icons by globbing files with a particular naming pattern. If there were no such icons, this used to do nothing, but silently. Commit fb7b8eea7d accidentally made this an error. More sensible would be to make it a warning. BUG: 354610 REVIEW: 125931 --- tests/ECMInstallIconsTest/CMakeLists.txt | 1 + tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt (limited to 'tests') diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt index 738cba91..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 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) -- cgit v1.2.1 From 994940ae780a860935f5321830fab1955a687b44 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:20:15 +0000 Subject: Revert "Fix ECMPoQmToolsTest." This commit is dependent on 009c480413910e8c1a18f4d1420f4a517ea606e6, which is the primary commit to be reverted. This reverts commit 39484722101730d4f1a4bccbc5467c0eb2cc0f6f. --- tests/ECMPoQmToolsTest/check.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 6e6d46fe..8089db6e 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -62,7 +62,7 @@ if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") foreach(lang en de fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" - LANGUAGE=${lang} "${${exec}_EXEC}" + LC_ALL=${lang} "${${exec}_EXEC}" OUTPUT_VARIABLE output ) string(STRIP "${output}" stripped_output) -- cgit v1.2.1 From 9d4be698a3a9a0b81730d2d54de5dd33b7dc61dc Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:23:14 +0000 Subject: Revert "Change ecm_create_po_loader test language to German." This commit is dependent on 009c480413910e8c1a18f4d1420f4a517ea606e6, which is the primary commit to be reverted. This reverts commit 0496f8ae020c497b5f65234063150781d023f8ba. --- tests/ECMPoQmToolsTest/check.cmake.in | 6 +++--- tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po | 22 ---------------------- tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po (limited to 'tests') diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 8089db6e..2f0cc205 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -23,7 +23,7 @@ set(exp_files "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" + "share/locale/en_GB/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" @@ -55,11 +55,11 @@ 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") + set(exp_output_en_GB "british english text:british english plural form 5") # no french translation provided -> english fallback set(exp_output_fr "${exp_output_en}") foreach(exec TR_TEST TR_THREAD_TEST) - foreach(lang en de fr) + foreach(lang en en_GB fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" LC_ALL=${lang} "${${exec}_EXEC}" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po deleted file mode 100644 index 6f3e328f..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -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_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po new file mode 100644 index 00000000..ec5ad857 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/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_GB\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "british english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "british english singular form %n" +msgstr[1] "british english plural form %n" -- cgit v1.2.1 From c58a8eefb05d0749bb4cc26a6cd74dee34e1f4be Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:23:21 +0000 Subject: Revert "Add license to tests." This commit is dependent on 009c480413910e8c1a18f4d1420f4a517ea606e6, which is the primary commit to be reverted. This reverts commit 634a0a2d3d7ba1bec2bae846acf0faf6184f4c71. --- tests/ECMPoQmToolsTest/tr_test.cpp | 27 ------------------------ tests/ECMPoQmToolsTest/tr_thread_test.cpp | 27 ------------------------ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 27 ------------------------ 3 files changed, 81 deletions(-) (limited to 'tests') diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp index 6536b60d..be5d3427 100644 --- a/tests/ECMPoQmToolsTest/tr_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -1,30 +1,3 @@ -/* - * Copyright 2015 Alex Merry - * - * 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 #include diff --git a/tests/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp index e128dc9d..3ed30ee1 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test.cpp @@ -1,30 +1,3 @@ -/* - * Copyright 2015 Alex Merry - * - * 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 #include #include diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp index d13539e2..b9000ffa 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp @@ -1,30 +1,3 @@ -/* - * Copyright 2015 Alex Merry - * - * 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 #include -- cgit v1.2.1 From 6745bd7e4796560959bb67e33b7c7f86f96a5a94 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:23:22 +0000 Subject: Revert "Make sure we load translations on the main thread." This broke the build for projects which used ecm_create_qm_loader in unusual ways. A better approach is coming, but won't be in e-c-m 5.16. This reverts commit 009c480413910e8c1a18f4d1420f4a517ea606e6. CCBUG: 346188 CCMAIL: release-team@kde.org CCMAIL: kde-buildsystem@kde.org --- tests/CMakeLists.txt | 4 +- tests/ECMPoQmToolsTest/CMakeLists.txt | 32 ++------- tests/ECMPoQmToolsTest/check.cmake.in | 81 ---------------------- tests/ECMPoQmToolsTest/check_conf.cmake.in | 2 - tests/ECMPoQmToolsTest/check_tree.cmake.in | 61 ++++++++++++++++ tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po | 22 ------ tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ------ tests/ECMPoQmToolsTest/tr_test.cpp | 16 ----- tests/ECMPoQmToolsTest/tr_thread_test.cpp | 68 ------------------ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 12 ---- 10 files changed, 68 insertions(+), 252 deletions(-) delete mode 100644 tests/ECMPoQmToolsTest/check.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/check_conf.cmake.in create mode 100644 tests/ECMPoQmToolsTest/check_tree.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po delete mode 100644 tests/ECMPoQmToolsTest/tr_test.cpp delete mode 100644 tests/ECMPoQmToolsTest/tr_thread_test.cpp delete mode 100644 tests/ECMPoQmToolsTest/tr_thread_test_module.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9e6de12f..8a75ae61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,13 +101,13 @@ add_test_macro(ECMInstallIconsTest ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/check_tree.cmake" ) -if (Qt5Core_FOUND AND Qt5LinguistTools_FOUND) +if (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.cmake" + ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check_tree.cmake" ) endif() diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index e08a2b8c..15351d2f 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -9,14 +9,9 @@ file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}") include(ECMPoQmTools) -include(../test_helpers.cmake) - -unset(QMLOADER_FILES) -ecm_create_qm_loader(QMLOADER_FILES catalog) -assert_var_defined(QMLOADER_FILES) - -# These will be used to test the above-generated loader -ecm_install_po_files_as_qm(tr_test-po) +# Should create ${CMAKE_CURRENT_BINARY_DIR}/qmloader.cpp and set QMLOADER_PATH +# to its path +ecm_create_qm_loader(QMLOADER_PATH catalog) # Should create a process-and-install.qm file and install it ecm_process_po_files_as_qm(fr ALL @@ -44,22 +39,5 @@ ecm_install_po_files_as_qm(po-custom-dir1) set(LOCALE_INSTALL_DIR custom-dir2) ecm_install_po_files_as_qm(po-custom-dir2) -find_package(Qt5Core CONFIG REQUIRED) - -add_executable(tr_test tr_test.cpp ${QMLOADER_FILES}) -target_link_libraries(tr_test PRIVATE Qt5::Core) - -add_library(tr_thread_module MODULE tr_thread_test_module.cpp ${QMLOADER_FILES}) -target_link_libraries(tr_thread_module PRIVATE Qt5::Core) - -add_executable(tr_thread_test tr_thread_test.cpp) -set_target_properties(tr_thread_test PROPERTIES AUTOMOC ON) -target_include_directories(tr_thread_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") -target_compile_definitions(tr_thread_test PRIVATE "MODULE_PATH=\"$\"") -target_link_libraries(tr_thread_test PRIVATE Qt5::Core) - -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) +# this will be run by CTest +configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in deleted file mode 100644 index 2f0cc205..00000000 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ /dev/null @@ -1,81 +0,0 @@ -set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") -include("${BINARY_DIR}/check_conf.cmake") - -set(fail OFF) - -macro(mark_failed msg) - message(WARNING "FAIL: ${msg}") - set(fail ON) -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}/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/en_GB/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" - "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" -) -file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") -list(SORT exp_files) -list(SORT actual_files) - -if(NOT exp_files STREQUAL actual_files) - foreach(f ${exp_files}) - list(FIND actual_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was expected, but not found") - set(fail ON) - endif() - endforeach() - foreach(f ${actual_files}) - list(FIND exp_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was found, but not expected") - 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_en_GB "british english text:british english plural form 5") - # no french translation provided -> english fallback - set(exp_output_fr "${exp_output_en}") - foreach(exec TR_TEST TR_THREAD_TEST) - foreach(lang en en_GB fr) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" - LC_ALL=${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) - message(FATAL_ERROR "Test failed!") -endif() diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in deleted file mode 100644 index 0bbab1d9..00000000 --- a/tests/ECMPoQmToolsTest/check_conf.cmake.in +++ /dev/null @@ -1,2 +0,0 @@ -set(TR_TEST_EXEC "$") -set(TR_THREAD_TEST_EXEC "$") diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check_tree.cmake.in new file mode 100644 index 00000000..9f4f7c0d --- /dev/null +++ b/tests/ECMPoQmToolsTest/check_tree.cmake.in @@ -0,0 +1,61 @@ +set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") +set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +set(QMLOADER_PATH "@QMLOADER_PATH@") + +set(fail OFF) + +macro(mark_failed msg) + message(WARNING "FAIL: ${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) + 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" + "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" + "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" +) +file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +list(SORT exp_files) +list(SORT actual_files) + +if(NOT exp_files STREQUAL actual_files) + foreach(f ${exp_files}) + list(FIND actual_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was expected, but not found") + set(fail ON) + endif() + endforeach() + foreach(f ${actual_files}) + list(FIND exp_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was found, but not expected") + set(fail ON) + endif() + endforeach() +endif() + +if (fail) + message(FATAL_ERROR "Test failed!") +endif() diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po deleted file mode 100644 index 2a7b6d28..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -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-po/en_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po deleted file mode 100644 index ec5ad857..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -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_GB\n" -"X-Qt-Contexts: true\n" - -#: main.cpp:12 -msgctxt "testcontext|" -msgid "test string" -msgstr "british english text" - -#: main.cpp:13 -#, qt-format -#| msgid "test plural" -msgctxt "testcontext|" -msgid "test plural %n" -msgid_plural "test plural %n" -msgstr[0] "british english singular form %n" -msgstr[1] "british english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp deleted file mode 100644 index be5d3427..00000000 --- a/tests/ECMPoQmToolsTest/tr_test.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -#include - -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/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp deleted file mode 100644 index 3ed30ee1..00000000 --- a/tests/ECMPoQmToolsTest/tr_thread_test.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include - -class Thread : public QThread -{ - Q_OBJECT - - QLibrary *m_lib; - -public: - Thread() - : m_lib(0) - {} - ~Thread() - { - delete m_lib; - } - -Q_SIGNALS: - void libraryLoaded(); - -public Q_SLOTS: - void printStrings() - { - // NB: this will run on the *main* event loop. - QFunctionPointer print_strings = m_lib->resolve("print_strings"); - if (print_strings) { - print_strings(); - } else { - qFatal("Could not resolve print_strings: %s", m_lib->errorString().toUtf8().data()); - } - - QCoreApplication::instance()->quit(); - } -protected: - void run() - { - m_lib = new QLibrary(MODULE_PATH); - - if (!m_lib->load()) { - qFatal("Could not load module: %s", m_lib->errorString().toUtf8().data()); - } - - // Queue a call to printStrings() on the main event loop (giving the - // translations a chance to be loaded). - QMetaObject::invokeMethod(this, "printStrings", Qt::QueuedConnection); - } -}; - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - Thread thread; - - // Start the thread *after* QCoreApplication is started (otherwise the - // plugin's startup function won't be run on the Thread, and we won't test - // what we wanted to test). - QMetaObject::invokeMethod(&thread, "start", Qt::QueuedConnection); - - app.exec(); - - return 0; -} - -#include "tr_thread_test.moc" diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp deleted file mode 100644 index b9000ffa..00000000 --- a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -#include - -extern "C" Q_DECL_EXPORT void print_strings() -{ - QTextStream output(stdout); - - output << QCoreApplication::translate("testcontext", "test string") << ":"; - output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; -} -- cgit v1.2.1 From c88bc78e0ca3834c46b89ca9d14b404751da5d4a Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 14 Oct 2015 12:18:40 +0100 Subject: Add unit test for ecm_create_qm_loader. This is based on commit 6745bd7e4796560959bb67e33b7c7f86f96a5a94 (and the subsequent fix-up commits). --- tests/CMakeLists.txt | 4 +- tests/ECMPoQmToolsTest/CMakeLists.txt | 57 +++++++++++++++-- tests/ECMPoQmToolsTest/check.cmake.in | 81 +++++++++++++++++++++++++ tests/ECMPoQmToolsTest/check_conf.cmake.in | 2 + tests/ECMPoQmToolsTest/check_tree.cmake.in | 61 ------------------- tests/ECMPoQmToolsTest/subdir/CMakeLists.txt | 5 ++ tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po | 22 +++++++ tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po | 22 +++++++ tests/ECMPoQmToolsTest/tr_test.cpp | 43 +++++++++++++ 9 files changed, 229 insertions(+), 68 deletions(-) create mode 100644 tests/ECMPoQmToolsTest/check.cmake.in create mode 100644 tests/ECMPoQmToolsTest/check_conf.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/check_tree.cmake.in create mode 100644 tests/ECMPoQmToolsTest/subdir/CMakeLists.txt create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a75ae61..9e6de12f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,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/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.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in new file mode 100644 index 00000000..ab434d2e --- /dev/null +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -0,0 +1,81 @@ +set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") +set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +include("${BINARY_DIR}/check_conf.cmake") + +set(fail OFF) + +macro(mark_failed msg) + message(WARNING "FAIL: ${msg}") + set(fail ON) +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}/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" + "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" +) +file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +list(SORT exp_files) +list(SORT actual_files) + +if(NOT exp_files STREQUAL actual_files) + foreach(f ${exp_files}) + list(FIND actual_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was expected, but not found") + set(fail ON) + endif() + endforeach() + foreach(f ${actual_files}) + list(FIND exp_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was found, but not expected") + 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) + message(FATAL_ERROR "Test failed!") +endif() 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 "$") +set(TR_TEST_SUBDIR_EXEC "$") diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check_tree.cmake.in deleted file mode 100644 index 9f4f7c0d..00000000 --- a/tests/ECMPoQmToolsTest/check_tree.cmake.in +++ /dev/null @@ -1,61 +0,0 @@ -set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") -set(QMLOADER_PATH "@QMLOADER_PATH@") - -set(fail OFF) - -macro(mark_failed msg) - message(WARNING "FAIL: ${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) - 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" - "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" - "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" -) -file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") -list(SORT exp_files) -list(SORT actual_files) - -if(NOT exp_files STREQUAL actual_files) - foreach(f ${exp_files}) - list(FIND actual_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was expected, but not found") - set(fail ON) - endif() - endforeach() - foreach(f ${actual_files}) - list(FIND exp_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was found, but not expected") - set(fail ON) - endif() - endforeach() -endif() - -if (fail) - message(FATAL_ERROR "Test failed!") -endif() 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 + * + * 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 +#include + +#include + +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; +} -- cgit v1.2.1