From 366d6678994813783fda289f68c609d1cb91048d Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 4 Jan 2025 09:32:30 +0000 Subject: [PATCH] Improve debuggability of autogenerated_files.py Signed-off-by: Hanno Becker --- scripts/autogenerate_files.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/autogenerate_files.py b/scripts/autogenerate_files.py index 99279dfa1..2b3a812f3 100644 --- a/scripts/autogenerate_files.py +++ b/scripts/autogenerate_files.py @@ -57,9 +57,15 @@ def update_file(filename, content, dry_run=False): with open(filename, "r") as f: current_content = f.read() if current_content != content: + filename_new = f"{filename}.new" print( - f"Autogenerated file {filename} needs updating. Have you called scripts/autogenerated.py?" + f"Autogenerated file {filename} needs updating. Have you called scripts/autogenerated.py?", + file=sys.stderr, ) + print(f"Writing new version to {filename_new}", file=sys.stderr) + with open(filename_new, "w") as f: + f.write(content) + subprocess.run(["diff", filename, filename_new]) exit(1)