diff options
Diffstat (limited to 'tools/arch-census.py')
| -rwxr-xr-x | tools/arch-census.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/arch-census.py b/tools/arch-census.py index b493ea8..09f4201 100755 --- a/tools/arch-census.py +++ b/tools/arch-census.py @@ -285,8 +285,20 @@ def main(): data = census() if args.write_budget: + # Preserve any section another tool owns (for example `test_surface`, + # written by tools/test-surface.py). Two writers of one file must not + # erase each other, or the ratchet silently stops checking one axis. + existing = {} + if os.path.exists(args.write_budget): + try: + existing = json.load(open(args.write_budget)) + except (ValueError, OSError): + existing = {} + out = dict(existing) + out["modules"] = data["modules"] + out["totals"] = data["totals"] with open(args.write_budget, "w") as handle: - json.dump({"modules": data["modules"], "totals": data["totals"]}, handle, indent=2, + json.dump(out, handle, indent=2, sort_keys=True) handle.write("\n") print(f"wrote {args.write_budget}") |
