Refactor code structure for improved readability and maintainability; removed redundant code blocks and optimized function calls.
This commit is contained in:
8
tests/reachability/scripts/README.md
Normal file
8
tests/reachability/scripts/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Reachability Scripts
|
||||
|
||||
- `update_corpus_manifest.py` — regenerate `tests/reachability/corpus/manifest.json` with SHA-256 hashes for all corpus files. Deterministic; no network access.
|
||||
|
||||
Usage:
|
||||
```bash
|
||||
python tests/reachability/scripts/update_corpus_manifest.py
|
||||
```
|
||||
38
tests/reachability/scripts/update_corpus_manifest.py
Normal file
38
tests/reachability/scripts/update_corpus_manifest.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Regenerate reachability corpus manifest deterministically.
|
||||
Usage: python tests/reachability/scripts/update_corpus_manifest.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1] / "corpus"
|
||||
FILE_LIST = ["expect.yaml", "callgraph.static.json", "vex.openvex.json"]
|
||||
|
||||
def sha256(path: Path) -> str:
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
def main() -> int:
|
||||
entries = []
|
||||
for lang_dir in sorted(p for p in ROOT.iterdir() if p.is_dir()):
|
||||
for case_dir in sorted(p for p in lang_dir.iterdir() if p.is_dir()):
|
||||
files = {}
|
||||
for name in FILE_LIST:
|
||||
path = case_dir / name
|
||||
if not path.exists():
|
||||
raise SystemExit(f"missing {path}")
|
||||
files[name] = sha256(path)
|
||||
entries.append({
|
||||
"id": case_dir.name,
|
||||
"language": lang_dir.name,
|
||||
"files": files,
|
||||
})
|
||||
manifest_path = ROOT / "manifest.json"
|
||||
manifest_path.write_text(json.dumps(entries, indent=2, sort_keys=True))
|
||||
print(f"wrote {manifest_path} ({len(entries)} entries)")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user