summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/linguist/test_i18n_exclusion/check_ts_file.cmake
blob: 45b9b434a25b71de5286951ad1f1d3e722152e77 (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
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

set(ts_file "test_i18n_exclusion_de.ts")
file(READ "${ts_file}" ts_file_content)

set(expected_strings
    "<source>Hello from app1!</source>"
    "<source>Hello from MyObject1!</source>"
)
foreach(needle IN LISTS expected_strings)
    string(FIND "${ts_file_content}" "${needle}" pos)
    if(pos EQUAL "-1")
        message(FATAL_ERROR
            "Expected string '${needle}' was not found in '${ts_file}'. "
            "The file content is:\n${ts_file_content}"
        )
    endif()
endforeach()

set(forbidden_strings
    "<source>Hello from MyObject2!</source>"
    "<source>Hello from test1!</source>"
    "<source>excluded1</source>"
    "<source>excluded2</source>"
    "<source>excluded3</source>"
    "<source>excluded4</source>"
)
foreach(needle IN LISTS forbidden_strings)
    string(FIND "${ts_file_content}" "${needle}" pos)
    if(NOT pos EQUAL "-1")
        message(FATAL_ERROR
            "Excluded string '${needle}' was found in '${ts_file}'. "
            "The file content is:\n${ts_file_content}"
        )
    endif()
endforeach()