refactor: establish standalone application boundary
This commit is contained in:
+12
-15
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import sqlite3
|
||||
import subprocess
|
||||
@@ -13,6 +14,7 @@ from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
FRONTEND_ROOT = ROOT / "frontend"
|
||||
RUNTIME_ROOT = ROOT / "runtime"
|
||||
E2E_URL = "http://127.0.0.1:8876/index.html"
|
||||
|
||||
|
||||
@@ -21,19 +23,8 @@ def run(label: str, command: list[str]) -> None:
|
||||
subprocess.run(command, cwd=ROOT, check=True)
|
||||
|
||||
|
||||
def python_test_command(preservation_baseline: bool | None = None) -> list[str]:
|
||||
if preservation_baseline is None:
|
||||
preservation_baseline = (ROOT.parent / "static" / "app.js").is_file()
|
||||
if preservation_baseline:
|
||||
return [sys.executable, "-m", "unittest", "discover", "-s", "tests"]
|
||||
modules = [
|
||||
f"tests.{path.stem}"
|
||||
for path in sorted((ROOT / "tests").glob("test_*.py"))
|
||||
if not path.stem.startswith("test_preservation_")
|
||||
]
|
||||
if not modules:
|
||||
raise RuntimeError("no standalone candidate tests found")
|
||||
return [sys.executable, "-m", "unittest", *modules]
|
||||
def python_test_command() -> list[str]:
|
||||
return [sys.executable, "-m", "unittest", "discover", "-s", "tests"]
|
||||
|
||||
|
||||
def verify_git_diff() -> None:
|
||||
@@ -121,7 +112,7 @@ def stop_e2e_server(process: subprocess.Popen[bytes] | None) -> None:
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Verify the modular preservation candidate"
|
||||
description="Verify the standalone application"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--e2e",
|
||||
@@ -130,6 +121,10 @@ def main() -> int:
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
cache_root = RUNTIME_ROOT / "cache" / "python"
|
||||
cache_root.mkdir(parents=True, exist_ok=True)
|
||||
os.environ["PYTHONPYCACHEPREFIX"] = str(cache_root)
|
||||
|
||||
run("python", python_test_command())
|
||||
run(
|
||||
"api-registry",
|
||||
@@ -142,7 +137,9 @@ def main() -> int:
|
||||
node = shutil.which("node")
|
||||
if not node:
|
||||
raise RuntimeError("node is required for JavaScript syntax checks")
|
||||
scripts = sorted(FRONTEND_ROOT.rglob("*.js"))
|
||||
scripts = sorted(
|
||||
path for path in FRONTEND_ROOT.rglob("*") if path.suffix in {".js", ".mjs"}
|
||||
)
|
||||
if not scripts:
|
||||
raise RuntimeError(f"no JavaScript files found under {FRONTEND_ROOT}")
|
||||
for script in scripts:
|
||||
|
||||
Reference in New Issue
Block a user