Debian Codegraph @

tests/auto/cmake/linguist/test_i18n_exclusion/check_ts_file.cmake

raw
1 # Copyright (C) 2023 The Qt Company Ltd.
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 set(ts_file "test_i18n_exclusion_de.ts")
5 file(READ "${ts_file}" ts_file_content)
6
7 set(expected_strings
8 "<source>Hello from app1!</source>"
9 "<source>Hello from MyObject1!</source>"
10 )
11 foreach(needle IN LISTS expected_strings)
12 string(FIND "${ts_file_content}" "${needle}" pos)
13 if(pos EQUAL "-1")
14 message(FATAL_ERROR
15 "Expected string '${needle}' was not found in '${ts_file}'. "
16 "The file content is:\n${ts_file_content}"
17 )
18 endif()
19 endforeach()
20
21 set(forbidden_strings
22 "<source>Hello from MyObject2!</source>"
23 "<source>Hello from test1!</source>"
24 "<source>excluded1</source>"
25 "<source>excluded2</source>"
26 "<source>excluded3</source>"
27 "<source>excluded4</source>"
28 "<source>excluded5</source>"
29 )
30 foreach(needle IN LISTS forbidden_strings)
31 string(FIND "${ts_file_content}" "${needle}" pos)
32 if(NOT pos EQUAL "-1")
33 message(FATAL_ERROR
34 "Excluded string '${needle}' was found in '${ts_file}'. "
35 "The file content is:\n${ts_file_content}"
36 )
37 endif()
38 endforeach()