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/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 ++++ 9 files changed, 250 insertions(+), 66 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/ECMPoQmToolsTest') 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/ECMPoQmToolsTest') 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/ECMPoQmToolsTest') 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/ECMPoQmToolsTest') 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 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/ECMPoQmToolsTest') 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/ECMPoQmToolsTest') 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/ECMPoQmToolsTest') 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/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 ---- 9 files changed, 66 insertions(+), 250 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/ECMPoQmToolsTest') 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/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 +++++++++++++ 8 files changed, 227 insertions(+), 66 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/ECMPoQmToolsTest') 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