Warning, /frameworks/extra-cmake-modules/tests/ECMPoQmToolsTest/check.cmake.in is written in an unsupported language. File is not indexed.
0001 set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
0002 set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@")
0003 include("${BINARY_DIR}/check_conf.cmake")
0004
0005 set(fail OFF)
0006
0007 macro(mark_failed msg)
0008 message(WARNING "FAIL: ${msg}")
0009 set(fail ON)
0010 endmacro()
0011
0012 macro(check_exists file)
0013 message(STATUS "Checking for ${file}")
0014 if (NOT EXISTS ${file})
0015 mark_failed("File \"${file}\" does not exist")
0016 endif()
0017 endmacro()
0018
0019 check_exists(${BINARY_DIR}/ECMPoQm/fr/only-process.qm)
0020
0021 set(exp_files
0022 "share/locale/fr/LC_MESSAGES/process-and-install.qm"
0023 "share/locale/es/LC_MESSAGES/install-test.qm"
0024 "share/locale/fr/LC_MESSAGES/install-test.qm"
0025 "share/locale/en/LC_MESSAGES/catalog.qm"
0026 "share/locale/en/LC_MESSAGES/catalog2.qm"
0027 "share/locale/de/LC_MESSAGES/catalog.qm"
0028 "share/locale/de/LC_MESSAGES/catalog2.qm"
0029 "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm"
0030 "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm"
0031 "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm"
0032 "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm"
0033 )
0034 file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*")
0035 list(SORT exp_files)
0036 list(SORT actual_files)
0037
0038 if(NOT exp_files STREQUAL actual_files)
0039 foreach(f ${exp_files})
0040 list(FIND actual_files "${f}" result)
0041 if(result EQUAL -1)
0042 message(WARNING "${f} was expected, but not found")
0043 set(fail ON)
0044 endif()
0045 endforeach()
0046 foreach(f ${actual_files})
0047 list(FIND exp_files "${f}" result)
0048 if(result EQUAL -1)
0049 message(WARNING "${f} was found, but not expected")
0050 set(fail ON)
0051 endif()
0052 endforeach()
0053 else()
0054 message(STATUS "Installed translations in expected locations")
0055 endif()
0056
0057 # we know we can modify the executable environment on Linux
0058 if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux")
0059 set(exp_output_catalog_en "english text:english plural form 5")
0060 set(exp_output_catalog_de "german text:german plural form 5")
0061 # no de_AT translation -> should fall back to de
0062 set(exp_output_catalog_de_AT "${exp_output_catalog_de}")
0063 # no french translation provided -> english fallback
0064 set(exp_output_catalog_fr "${exp_output_catalog_en}")
0065
0066 set(exp_output_catalog2_en "2nd english text:2nd english plural form 5")
0067 set(exp_output_catalog2_de "2nd german text:2nd german plural form 5")
0068 # no de_AT translation -> should fall back to de
0069 set(exp_output_catalog2_de_AT "${exp_output_catalog2_de}")
0070 # no french translation provided -> english fallback
0071 set(exp_output_catalog2_fr "${exp_output_catalog2_en}")
0072
0073 function(check_translations name exec catalog_name)
0074 foreach(lang en de de_AT fr)
0075 execute_process(
0076 COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share"
0077 LANG=${lang} "${exec}"
0078 OUTPUT_VARIABLE output
0079 )
0080 string(STRIP "${output}" stripped_output)
0081 if(NOT stripped_output STREQUAL exp_output_${catalog_name}_${lang})
0082 message(WARNING "${name}[${lang}] output was \"${stripped_output}\", but expected \"${exp_output_${catalog_name}_${lang}}\"")
0083 set(fail ON PARENT_SCOPE)
0084 else()
0085 message(STATUS "${name}[${lang}] output was \"${stripped_output}\", as expected")
0086 endif()
0087 endforeach()
0088 endfunction()
0089
0090 check_translations(TR_TEST "${TR_TEST_EXEC}" catalog)
0091 check_translations(TR_TEST_TARGET "${TR_TEST_TARGET_EXEC}" catalog)
0092 check_translations(TR_TEST_2 "${TR_TEST_2_EXEC}" catalog2)
0093
0094 check_translations(TR_TEST_SUBDIR "${TR_TEST_SUBDIR_EXEC}" catalog)
0095
0096 check_translations(TR_THREAD_TEST "${TR_THREAD_TEST_EXEC}" catalog)
0097 check_translations(TR_THREAD_TEST_2 "${TR_THREAD_TEST_2_EXEC}" catalog2)
0098 endif()
0099
0100 if (fail)
0101 message(FATAL_ERROR "Test failed!")
0102 endif()