blob: aeef8e42066ef8398440856ef958b101a4c42355 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
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/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"
"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_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_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}"
OUTPUT_VARIABLE output
)
string(STRIP "${output}" stripped_output)
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 PARENT_SCOPE)
else()
message(STATUS "${name}[${lang}] output was \"${stripped_output}\", as expected")
endif()
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)
check_translations(TR_THREAD_TEST "${TR_THREAD_TEST_EXEC}" catalog)
check_translations(TR_THREAD_TEST_2 "${TR_THREAD_TEST_2_EXEC}" catalog2)
endif()
if (fail)
message(FATAL_ERROR "Test failed!")
endif()
|