diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ECMPoQmToolsTest/CMakeLists.txt | 49 | ||||
| -rw-r--r-- | tests/ECMPoQmToolsTest/check.cmake.in | 31 | ||||
| -rw-r--r-- | tests/ECMPoQmToolsTest/check_conf.cmake.in | 1 | ||||
| -rw-r--r-- | tests/ECMPoQmToolsTest/tr_test-po/de/catalog2.po | 22 | ||||
| -rw-r--r-- | tests/ECMPoQmToolsTest/tr_test-po/en/catalog2.po | 22 | 
5 files changed, 103 insertions, 22 deletions
| diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index 76d80141..73d2b427 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -12,9 +12,11 @@ include(ECMPoQmTools)  include(../test_helpers.cmake) -# -# ecm_process_po_files_as_qm -# +############################## +#                            # +# ecm_process_po_files_as_qm # +#                            # +##############################  # Should create a process-and-install.qm file and install it @@ -30,9 +32,11 @@ ecm_process_po_files_as_qm(fr ALL -# -# ecm_install_po_files_as_qm -# +############################## +#                            # +# 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 @@ -56,14 +60,19 @@ unset(LOCALE_INSTALL_DIR) -# -# ecm_create_qm_loader -# +######################## +#                      # +# ecm_create_qm_loader # +#                      # +########################  find_package(Qt5Core CONFIG REQUIRED)  ecm_install_po_files_as_qm(tr_test-po) +# +# single-threaded test +#  set(tr_test_SRCS      tr_test.cpp  ) @@ -72,10 +81,24 @@ 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 +# +# single-threaded test (different catalog name) +# +# This is to check we don't overwrite previously-generated files. +set(tr_test_2_SRCS +    tr_test.cpp +) +ecm_create_qm_loader(tr_test_2_SRCS catalog2) +add_executable(tr_test_2 ${tr_test_2_SRCS}) +target_link_libraries(tr_test_2 PRIVATE Qt5::Core) + + +# +# call to ecm_create_qm_loader is in a different CMakeLists.txt to where +# the target it is added to is defined +# +# This is not something we want people to do, 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) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index ab434d2e..5329b78d 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -23,7 +23,9 @@ 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/LC_MESSAGES/catalog2.qm"      "share/locale/de/LC_MESSAGES/catalog.qm" +    "share/locale/de/LC_MESSAGES/catalog2.qm"      "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm"      "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm"      "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" @@ -54,26 +56,37 @@ 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_catalog_en "english text:english plural form 5") +    set(exp_output_catalog_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) +    set(exp_output_catalog_fr "${exp_output_catalog_en}") + +    set(exp_output_catalog2_en "2nd english text:2nd english plural form 5") +    set(exp_output_catalog2_de "2nd german text:2nd german plural form 5") +    # no french translation provided -> english fallback +    set(exp_output_catalog2_fr "${exp_output_catalog2_en}") + +    function(check_translations name exec catalog_name)          foreach(lang en de fr)              execute_process(                  COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" -                    LANGUAGE=${lang} "${${exec}_EXEC}" +                    LANGUAGE=${lang} "${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}}\"") +            if(NOT stripped_output STREQUAL exp_output_${catalog_name}_${lang}) +                message(WARNING "${name}[${lang}] output was \"${stripped_output}\", but expected \"${exp_output_${catalog_name}_${lang}}\"")                  set(fail ON)              else() -                message(STATUS "${exec}[${lang}] output was \"${stripped_output}\", as expected") +                message(STATUS "${name}[${lang}] output was \"${stripped_output}\", as expected")              endif()          endforeach() -    endforeach() +    endfunction() + +    check_translations(TR_TEST "${TR_TEST_EXEC}" catalog) +    check_translations(TR_TEST_2 "${TR_TEST_2_EXEC}" catalog2) + +    check_translations(TR_TEST_SUBDIR "${TR_TEST_SUBDIR_EXEC}" catalog)  endif()  if (fail) diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in index 9ab02e72..7bd11c36 100644 --- a/tests/ECMPoQmToolsTest/check_conf.cmake.in +++ b/tests/ECMPoQmToolsTest/check_conf.cmake.in @@ -1,2 +1,3 @@  set(TR_TEST_EXEC "$<TARGET_FILE:tr_test>") +set(TR_TEST_2_EXEC "$<TARGET_FILE:tr_test_2>")  set(TR_TEST_SUBDIR_EXEC "$<TARGET_FILE:tr_test_subdir>") diff --git a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog2.po b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog2.po new file mode 100644 index 00000000..04631f32 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog2.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 "2nd german text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "2nd german singular form %n" +msgstr[1] "2nd german plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog2.po b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog2.po new file mode 100644 index 00000000..bd17bbf8 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog2.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 "2nd english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "2nd english singular form %n" +msgstr[1] "2nd english plural form %n" | 
