1
0

show-only_json-v1_check.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. from show_only_json_check import *
  2. def check_kind(k):
  3. assert is_string(k)
  4. assert k == "ctestInfo"
  5. def check_version(v):
  6. assert is_dict(v)
  7. assert sorted(v.keys()) == ["major", "minor"]
  8. assert is_int(v["major"])
  9. assert is_int(v["minor"])
  10. assert v["major"] == 1
  11. assert v["minor"] == 0
  12. def check_backtracegraph(b):
  13. assert is_dict(b)
  14. assert sorted(b.keys()) == ["commands", "files", "nodes"]
  15. check_backtracegraph_commands(b["commands"])
  16. check_backtracegraph_files(b["files"])
  17. check_backtracegraph_nodes(b["nodes"])
  18. def check_backtracegraph_commands(c):
  19. assert is_list(c)
  20. assert len(c) == 1
  21. assert is_string(c[0])
  22. assert c[0] == "add_test"
  23. def check_backtracegraph_files(f):
  24. assert is_list(f)
  25. assert len(f) == 2
  26. assert is_string(f[0])
  27. assert is_string(f[1])
  28. assert f[0] == "file1"
  29. assert f[1] == "file0"
  30. def check_backtracegraph_nodes(n):
  31. assert is_list(n)
  32. assert len(n) == 2
  33. node = n[0]
  34. assert is_dict(node)
  35. assert sorted(node.keys()) == ["file"]
  36. assert is_int(node["file"])
  37. assert node["file"] == 1
  38. node = n[1]
  39. assert is_dict(node)
  40. assert sorted(node.keys()) == ["command", "file", "line", "parent"]
  41. assert is_int(node["command"])
  42. assert is_int(node["file"])
  43. assert is_int(node["line"])
  44. assert is_int(node["parent"])
  45. assert node["command"] == 0
  46. assert node["file"] == 0
  47. assert node["line"] == 1
  48. assert node["parent"] == 0
  49. def check_command(c):
  50. assert is_list(c)
  51. assert len(c) == 3
  52. assert is_string(c[0])
  53. check_re(c[0], "/cmake(\.exe)?$")
  54. assert is_string(c[1])
  55. assert c[1] == "-E"
  56. assert is_string(c[2])
  57. assert c[2] == "echo"
  58. def check_willfail_property(p):
  59. assert is_dict(p)
  60. assert sorted(p.keys()) == ["name", "value"]
  61. assert is_string(p["name"])
  62. assert is_bool(p["value"])
  63. assert p["name"] == "WILL_FAIL"
  64. assert p["value"] == True
  65. def check_workingdir_property(p):
  66. assert is_dict(p)
  67. assert sorted(p.keys()) == ["name", "value"]
  68. assert is_string(p["name"])
  69. assert is_string(p["value"])
  70. assert p["name"] == "WORKING_DIRECTORY"
  71. assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowOnly")
  72. def check_properties(p):
  73. assert is_list(p)
  74. assert len(p) == 2
  75. check_willfail_property(p[0])
  76. check_workingdir_property(p[1])
  77. def check_tests(t):
  78. assert is_list(t)
  79. assert len(t) == 1
  80. test = t[0]
  81. assert is_dict(test)
  82. assert sorted(test.keys()) == ["backtrace", "command", "name", "properties"]
  83. assert is_int(test["backtrace"])
  84. assert test["backtrace"] == 1
  85. check_command(test["command"])
  86. assert is_string(test["name"])
  87. assert test["name"] == "ShowOnly"
  88. check_properties(test["properties"])
  89. assert is_dict(ctest_json)
  90. assert sorted(ctest_json.keys()) == ["backtraceGraph", "kind", "tests", "version"]
  91. check_backtracegraph(ctest_json["backtraceGraph"])
  92. check_kind(ctest_json["kind"])
  93. check_version(ctest_json["version"])
  94. check_tests(ctest_json["tests"])