#!/usr/bin/env python3 """Run public synthetic tests locally; never contact a vehicle or network.""" import os from pathlib import Path import shutil import subprocess import sys import tempfile ROOT = Path(__file__).resolve().parents[1] def run(*command): environment = dict(os.environ, PYTHONDONTWRITEBYTECODE="1") print("+ " + " ".join(str(part) for part in command), flush=True) subprocess.run(command, cwd=ROOT, env=environment, check=True) def main(): missing = [name for name in ("javac", "java", "php") if not shutil.which(name)] if missing: raise SystemExit("Required local tools are missing: " + ", ".join(missing)) run(sys.executable, "tools/check_publication.py") run(sys.executable, "-B", "-m", "unittest", "discover", "-s", "tests/python", "-v") sources = sorted( list((ROOT / "telemetry/java").rglob("*.java")) + list((ROOT / "weather/java").rglob("*.java")) + list((ROOT / "tests/java").glob("*.java")) ) with tempfile.TemporaryDirectory(prefix="niro-gen5w-public-tests-") as temporary: run("javac", "-encoding", "UTF-8", "-d", temporary, *map(str, sources)) for name in ( "com.chaegeon.niro.HscanRpmDecoderTest", "WeatherRefreshGateTest", "com.chaegeon.niro.WeatherRefreshCountersTest", ): run("java", "-cp", temporary, name) for source in sorted((ROOT / "backend/php").glob("*.php")): run("php", "-l", str(source)) for test in sorted((ROOT / "tests/php").glob("*Test.php")): run("php", str(test)) print("PASS: all public synthetic test programs completed") if __name__ == "__main__": main()