#!/usr/bin/env python3 """Verify text_stats.py works correctly.""" import json import subprocess import sys # Run the script on itself proc = subprocess.run( ['python3', '/root/.hermes/wizard-outputs/spark/text_stats.py', '/root/.hermes/wizard-outputs/spark/text_stats.py'], capture_output=True, text=True ) # Parse output try: data = json.loads(proc.stdout.strip()) except json.JSONDecodeError as e: print(f"FAIL: Invalid JSON output: {e}") sys.exit(1) # Verify schema errors = [] if 'path' not in data: errors.append("missing 'path' field") if 'lines' not in data: errors.append("missing 'lines' field") if 'words' not in data: errors.append("missing 'words' field") if 'chars' not in data: errors.append("missing 'chars' field") if errors: print(f"FAIL: {', '.join(errors)}") sys.exit(1) # Verify counts match expected values (from wc and word count) if data['lines'] != 38: errors.append(f"lines={data['lines']}, expected 38") if data['words'] != 114: errors.append(f"words={data['words']}, expected 114") if data['chars'] != 1030: errors.append(f"chars={data['chars']}, expected 1030") if errors: print(f"FAIL: {', '.join(errors)}") sys.exit(1) print("PASS: text_stats.py verified successfully") print(f" - paths: {data['path']}") print(f" - lines: {data['lines']}") print(f" - words: {data['words']}") print(f" - chars: {data['chars']}")