summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Fitzgerald <fitzgen@gmail.com>2016-10-17 15:10:20 -0700
committerNick Fitzgerald <fitzgen@gmail.com>2016-10-18 13:17:33 -0700
commit60c0531917eb4792a8012e821b773263873c3a1f (patch)
tree7e1170245138703f1dd8dd463e1247910e24caa7
parent7cea09c3a03bc058125e5a4476e92381b94e00d5 (diff)
Make tests/tools/run-bindgen.py check expectations if the rust path already exists
-rwxr-xr-xtests/tools/run-bindgen.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/tools/run-bindgen.py b/tests/tools/run-bindgen.py
index 0d8ed580..656c6ae5 100755
--- a/tests/tools/run-bindgen.py
+++ b/tests/tools/run-bindgen.py
@@ -19,7 +19,7 @@ if len(sys.argv) != 4:
flags = ["--no-unstable-rust"]
-with open(sys.argv[2]) as f:
+with open(c_path) as f:
for line in f:
if line.startswith(BINDGEN_FLAGS_PREFIX):
flags.extend(line.strip().split(BINDGEN_FLAGS_PREFIX)[1].split(" "))
@@ -40,11 +40,30 @@ env = os.environ.copy()
# https://forums.developer.apple.com/thread/9233
if "DYLD_LIBRARY_PATH" not in env and "LIBCLANG_PATH" in env:
env["DYLD_LIBRARY_PATH"] = env["LIBCLANG_PATH"]
-subprocess.check_call(base_command, cwd=os.getcwd(), env=env)
+# If the rust file already exists, read it now so we can compare its contents
+# before and after.
+original_rust_contents = None
+if os.path.isfile(rust_path):
+ with open(rust_path) as f:
+ original_rust_contents = f.read()
+
+subprocess.check_call(base_command, cwd=os.getcwd(), env=env)
name = None
with tempfile.NamedTemporaryFile(delete=False) as tests:
name = tests.name
subprocess.check_call(["rustc", "--test", sys.argv[3], "-o", tests.name])
subprocess.check_call([tests.name])
+
+if original_rust_contents is not None:
+ new_rust_contents = None
+ with open(rust_path) as f:
+ new_rust_contents = f.read()
+ if new_rust_contents != original_rust_contents:
+ print("Generated rust bindings do not match expectation!")
+ print("Expected rust bindings:")
+ print(original_rust_contents)
+ print("Actual rust bindings:")
+ print(new_rust_contents)
+ sys.exit(1)