cache-v2-check.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. from check_index import *
  2. def check_objects(o):
  3. assert is_list(o)
  4. assert len(o) == 1
  5. check_index_object(o[0], "cache", 2, 0, check_object_cache)
  6. def check_cache_entry(actual, expected):
  7. assert is_dict(actual)
  8. assert sorted(actual.keys()) == ["name", "properties", "type", "value"]
  9. assert is_string(actual["type"], expected["type"])
  10. assert is_string(actual["value"], expected["value"])
  11. def check_property(actual, expected):
  12. assert is_dict(actual)
  13. assert sorted(actual.keys()) == ["name", "value"]
  14. assert is_string(actual["value"], expected["value"])
  15. check_list_match(lambda a, e: is_string(a["name"], e["name"]), actual["properties"], expected["properties"], check=check_property)
  16. def check_object_cache(o):
  17. assert sorted(o.keys()) == ["entries", "kind", "version"]
  18. # The "kind" and "version" members are handled by check_index_object.
  19. check_list_match(lambda a, e: is_string(a["name"], e["name"]), o["entries"], [
  20. {
  21. "name": "CM_OPTION_BOOL",
  22. "type": "BOOL",
  23. "value": "OFF",
  24. "properties": [
  25. {
  26. "name": "HELPSTRING",
  27. "value": "Testing option()",
  28. },
  29. ],
  30. },
  31. {
  32. "name": "CM_SET_BOOL",
  33. "type": "BOOL",
  34. "value": "ON",
  35. "properties": [
  36. {
  37. "name": "HELPSTRING",
  38. "value": "Testing set(CACHE BOOL)",
  39. },
  40. {
  41. "name": "ADVANCED",
  42. "value": "1",
  43. },
  44. ],
  45. },
  46. {
  47. "name": "CM_SET_FILEPATH",
  48. "type": "FILEPATH",
  49. "value": "dir1/dir2/empty.txt",
  50. "properties": [
  51. {
  52. "name": "HELPSTRING",
  53. "value": "Testing set(CACHE FILEPATH)",
  54. },
  55. ],
  56. },
  57. {
  58. "name": "CM_SET_PATH",
  59. "type": "PATH",
  60. "value": "dir1/dir2",
  61. "properties": [
  62. {
  63. "name": "HELPSTRING",
  64. "value": "Testing set(CACHE PATH)",
  65. },
  66. {
  67. "name": "ADVANCED",
  68. "value": "ON",
  69. },
  70. ],
  71. },
  72. {
  73. "name": "CM_SET_STRING",
  74. "type": "STRING",
  75. "value": "test",
  76. "properties": [
  77. {
  78. "name": "HELPSTRING",
  79. "value": "Testing set(CACHE STRING)",
  80. },
  81. ],
  82. },
  83. {
  84. "name": "CM_SET_STRINGS",
  85. "type": "STRING",
  86. "value": "1",
  87. "properties": [
  88. {
  89. "name": "HELPSTRING",
  90. "value": "Testing set(CACHE STRING) with STRINGS",
  91. },
  92. {
  93. "name": "STRINGS",
  94. "value": "1;2;3;4",
  95. },
  96. ],
  97. },
  98. {
  99. "name": "CM_SET_INTERNAL",
  100. "type": "INTERNAL",
  101. "value": "int2",
  102. "properties": [
  103. {
  104. "name": "HELPSTRING",
  105. "value": "Testing set(CACHE INTERNAL)",
  106. },
  107. ],
  108. },
  109. {
  110. "name": "CM_SET_TYPE",
  111. "type": "STRING",
  112. "value": "1",
  113. "properties": [
  114. {
  115. "name": "HELPSTRING",
  116. "value": "Testing set(CACHE INTERNAL) with set_property(TYPE)",
  117. },
  118. {
  119. "name": "ADVANCED",
  120. "value": "0",
  121. },
  122. ],
  123. },
  124. ], check=check_cache_entry, allow_extra=True)
  125. assert is_dict(index)
  126. assert sorted(index.keys()) == ["cmake", "objects", "reply"]
  127. check_objects(index["objects"])