"""The whole LihonT runtime (settings screen, hooks, region, flags) compiles against Android. Nothing here is executed: screens need a device. This catches a broken edit in the UI code before a 350 MB build does. """ from pathlib import Path import shutil import subprocess import tempfile import unittest ROOT = Path(__file__).resolve().parents[1] class RuntimeCompileTest(unittest.TestCase): def test_runtime_sources_compile_against_android_jar(self): javac = shutil.which("javac") android_jar = ROOT / "tools" / "android.jar" if not javac: raise RuntimeError("This test requires a JDK with javac") self.assertTrue(android_jar.is_file(), "tools/android.jar must be available") sources = sorted(str(path) for path in (ROOT / "src" / "lihont" / "two").rglob("*.java")) self.assertTrue(sources) with tempfile.TemporaryDirectory(prefix="lihont-runtime-compile-") as out: result = subprocess.run( [javac, "--release", "17", "-nowarn", "-Xlint:-options", "-encoding", "UTF-8", "-cp", str(android_jar), "-d", out] + sources, capture_output=True, text=True, encoding="utf-8", timeout=120, ) self.assertEqual(result.returncode, 0, result.stdout + result.stderr) if __name__ == "__main__": unittest.main()