#!/usr/bin/env python3
"""Check that all scripts/*.py files can be compiled without syntax errors."""

import glob
import os
import py_compile

SCRIPTS_DIR = os.path.join(os.path.dirname(__file__), "..", "scripts")

def test_all_scripts_compile():
    """Verify every .py in scripts/ is syntactically valid."""
    scripts = sorted(glob.glob(os.path.join(SCRIPTS_DIR, "*.py")))
    assert scripts, f"No .py files found in {SCRIPTS_DIR}"
    errors = []
    for path in scripts:
        try:
            py_compile.compile(path, doraise=True)
        except py_compile.PyCompileError as e:
            errors.append(str(e))
    if errors:
        raise AssertionError("Syntax errors found:\n" + "\n".join(errors))

if __name__ == "__main__":
    test_all_scripts_compile()
    print("All scripts compile successfully.")
