summaryrefslogtreecommitdiff
path: root/tests/run-make/rustdoc-map-file/validate_json.py
diff options
context:
space:
mode:
authorJoshua Nelson <github@jyn.dev>2023-03-30 07:34:55 -0500
committerJoshua Nelson <github@jyn.dev>2023-03-30 07:34:55 -0500
commit433da1fc047bb39a263eefca4bdb2b1972f1d2ce (patch)
tree28540e78fdd5fdf158267e67495121ac64f0866a /tests/run-make/rustdoc-map-file/validate_json.py
parentf2d9a3d0771504f1ae776226a5799dcb4408a91a (diff)
downloadrust-433da1fc047bb39a263eefca4bdb2b1972f1d2ce.tar.gz
Move almost all run-make-fulldeps to run-make
They pass fine.
Diffstat (limited to 'tests/run-make/rustdoc-map-file/validate_json.py')
-rwxr-xr-xtests/run-make/rustdoc-map-file/validate_json.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/run-make/rustdoc-map-file/validate_json.py b/tests/run-make/rustdoc-map-file/validate_json.py
new file mode 100755
index 00000000000..5c14c90b70d
--- /dev/null
+++ b/tests/run-make/rustdoc-map-file/validate_json.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import json
+
+
+def find_redirect_map_file(folder, errors):
+ for root, dirs, files in os.walk(folder):
+ for name in files:
+ if not name.endswith("redirect-map.json"):
+ continue
+ with open(os.path.join(root, name)) as f:
+ data = json.load(f)
+ with open("expected.json") as f:
+ expected = json.load(f)
+ for key in expected:
+ if expected[key] != data.get(key):
+ errors.append("Expected `{}` for key `{}`, found: `{}`".format(
+ expected[key], key, data.get(key)))
+ else:
+ del data[key]
+ for key in data:
+ errors.append("Extra data not expected: key: `{}`, data: `{}`".format(
+ key, data[key]))
+ return True
+ return False
+
+
+if len(sys.argv) != 2:
+ print("Expected doc directory to check!")
+ sys.exit(1)
+
+errors = []
+if not find_redirect_map_file(sys.argv[1], errors):
+ print("Didn't find the map file in `{}`...".format(sys.argv[1]))
+ sys.exit(1)
+for err in errors:
+ print("=> {}".format(err))
+if len(errors) != 0:
+ sys.exit(1)