summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/FileAPI/cache-v2-check.py
blob: 756ef80807d10e6cef03846342b3edd0e48219a7 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from check_index import *

def check_objects(o):
    assert is_list(o)
    assert len(o) == 1
    check_index_object(o[0], "cache", 2, 0, check_object_cache)

def check_cache_entry(actual, expected):
    assert is_dict(actual)
    assert sorted(actual.keys()) == ["name", "properties", "type", "value"]

    assert is_string(actual["type"], expected["type"])
    assert is_string(actual["value"], expected["value"])

    def check_property(actual, expected):
        assert is_dict(actual)
        assert sorted(actual.keys()) == ["name", "value"]
        assert is_string(actual["value"], expected["value"])

    check_list_match(lambda a, e: is_string(a["name"], e["name"]), actual["properties"], expected["properties"], check=check_property)

def check_object_cache(o):
    assert sorted(o.keys()) == ["entries", "kind", "version"]
    # The "kind" and "version" members are handled by check_index_object.
    check_list_match(lambda a, e: is_string(a["name"], e["name"]), o["entries"], [
        {
            "name": "CM_OPTION_BOOL",
            "type": "BOOL",
            "value": "OFF",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing option()",
                },
            ],
        },
        {
            "name": "CM_SET_BOOL",
            "type": "BOOL",
            "value": "ON",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE BOOL)",
                },
                {
                    "name": "ADVANCED",
                    "value": "1",
                },
            ],
        },
        {
            "name": "CM_SET_FILEPATH",
            "type": "FILEPATH",
            "value": "dir1/dir2/empty.txt",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE FILEPATH)",
                },
            ],
        },
        {
            "name": "CM_SET_PATH",
            "type": "PATH",
            "value": "dir1/dir2",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE PATH)",
                },
                {
                    "name": "ADVANCED",
                    "value": "ON",
                },
            ],
        },
        {
            "name": "CM_SET_STRING",
            "type": "STRING",
            "value": "test",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE STRING)",
                },
            ],
        },
        {
            "name": "CM_SET_STRINGS",
            "type": "STRING",
            "value": "1",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE STRING) with STRINGS",
                },
                {
                    "name": "STRINGS",
                    "value": "1;2;3;4",
                },
            ],
        },
        {
            "name": "CM_SET_INTERNAL",
            "type": "INTERNAL",
            "value": "int2",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE INTERNAL)",
                },
            ],
        },
        {
            "name": "CM_SET_TYPE",
            "type": "STRING",
            "value": "1",
            "properties": [
                {
                    "name": "HELPSTRING",
                    "value": "Testing set(CACHE INTERNAL) with set_property(TYPE)",
                },
                {
                    "name": "ADVANCED",
                    "value": "0",
                },
            ],
        },
    ], check=check_cache_entry, allow_extra=True)

assert is_dict(index)
assert sorted(index.keys()) == ["cmake", "objects", "reply"]
check_objects(index["objects"])