Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a helper to check manifest.dump()
This is just for debugging, but I don't want to lose it.
  • Loading branch information
encukou committed Apr 28, 2022
commit b2280f6e772075266061c76c313411661b81f3cd
25 changes: 24 additions & 1 deletion Tools/scripts/stable_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import tomllib
import difflib
import shutil
import pprint
import sys
import os
import os.path
Expand Down Expand Up @@ -602,6 +603,28 @@ def check_private_names(manifest):
f'`{name}` is private (underscore-prefixed) and should be '
+ 'removed from the stable ABI list or or marked `abi_only`')

def check_dump(manifest, filename):
"""Check that manifest.dump() corresponds to the data.

Mainly useful when debugging this script.
"""
dumped = tomllib.loads('\n'.join(manifest.dump()))
with filename.open('rb') as file:
from_file = tomllib.load(file)
if dumped != from_file:
print(f'Dump differs from loaded data!', file=sys.stderr)
diff = difflib.unified_diff(
pprint.pformat(dumped).splitlines(),
pprint.pformat(from_file).splitlines(),
'<dumped>', str(filename),
lineterm='',
)
for line in diff:
print(line, file=sys.stderr)
return False
else:
return True

def main():
parser = argparse.ArgumentParser(
description=__doc__,
Expand Down Expand Up @@ -676,7 +699,7 @@ def main():
if args.dump:
for line in manifest.dump():
print(line)
results['dump'] = True
results['dump'] = check_dump(manifest, args.file)

for gen in generators:
filename = getattr(args, gen.var_name)
Expand Down