72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
"""Ejecuta las pruebas estaticas y, si esta disponible, la suite real de Godot.
|
|
|
|
Uso:
|
|
python tools/run_checks.py --static-only
|
|
python tools/run_checks.py --godot /ruta/al/ejecutable/godot
|
|
|
|
No considera las pruebas estaticas equivalentes a haber ejecutado el motor.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def run_step(command: list[str], *, timeout: int = 180) -> bool:
|
|
"""Conserva el diagnostico y detecta errores de script aunque el motor devuelva cero."""
|
|
print("\n> " + subprocess.list2cmdline(command), flush=True)
|
|
try:
|
|
result = subprocess.run(
|
|
command,
|
|
cwd=ROOT,
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
errors="replace",
|
|
timeout=timeout,
|
|
check=False,
|
|
)
|
|
except (OSError, subprocess.TimeoutExpired) as exc:
|
|
print(f"No se pudo completar la comprobacion: {exc}", file=sys.stderr)
|
|
return False
|
|
output = result.stdout + result.stderr
|
|
print(output, end="" if output.endswith("\n") else "\n")
|
|
return result.returncode == 0 and "SCRIPT ERROR:" not in output and "ERROR:" not in output
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--godot", help="Ejecutable de Godot 4.7.x, con ruta completa si no esta en PATH")
|
|
parser.add_argument("--static-only", action="store_true", help="Ejecutar solo los contratos de recursos")
|
|
args = parser.parse_args()
|
|
if not run_step([sys.executable, "-m", "unittest", "discover", "-s", "tests", "-v"]):
|
|
return 1
|
|
if args.static_only:
|
|
print("OK: pruebas estaticas. No se ha ejecutado Godot ni validado su fisica.")
|
|
return 0
|
|
executable = args.godot or shutil.which("godot") or shutil.which("godot4")
|
|
if not executable:
|
|
print("Pruebas estaticas OK. Falta Godot: indica --godot o utiliza --static-only.", file=sys.stderr)
|
|
return 2
|
|
if not run_step([executable, "--version"], timeout=20):
|
|
return 1
|
|
# --import espera a la importacion de recursos y termina el editor.
|
|
if not run_step([executable, "--headless", "--editor", "--path", str(ROOT), "--import"], timeout=300):
|
|
return 1
|
|
for script in sorted((ROOT / "tests").glob("test_*_runtime.gd")):
|
|
relative = "res://" + script.relative_to(ROOT).as_posix()
|
|
if not run_step([executable, "--headless", "--path", str(ROOT), "--script", relative]):
|
|
return 1
|
|
print("OK: importacion y todas las suites de Godot completadas.")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|