dymokomi/luce-3d
Source of release 0.9.1
#!/usr/bin/env python3
"""Exercise Base geometry and Luce scene composition in all compiled modes."""
import argparse
import os
from pathlib import Path
import subprocess
import tempfile
ROOT = Path(__file__).resolve().parents[1]
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--base", type=Path, default=Path(os.environ.get("LUCE_BASE", str(ROOT.parent / ("luce-base/build/luce-base.exe" if os.name == "nt" else "luce-base/build/luce-base")))))
parser.add_argument("--luce", type=Path, default=ROOT.parent / ("luce/build/luce.exe" if os.name == "nt" else "luce/build/luce"))
parser.add_argument("--opt", type=int, choices=range(4))
args = parser.parse_args()
modes = [["--native", "--opt", str(level)] for level in ([args.opt] if args.opt is not None else range(4))]
if args.opt is None:
modes += [["--backend=c"], ["--backend=c", "--release"]]
env = dict(os.environ, LUCE_BASE=str(args.base.resolve()))
compile_timeout = 600 if os.name == "nt" else 180
with tempfile.TemporaryDirectory(prefix="luce-3d-tests-") as temporary:
# Do not reuse cached package descriptions across compiler/dependency edits.
env["LUCE_CACHE"] = str(Path(temporary) / "cache")
binary = Path(temporary) / "test"
for compiler, entry in [(args.base, "main.lucb"), (args.luce, "objects.luc"), (args.luce, "custom.luc")]:
for flags in modes:
subprocess.run([str(compiler.resolve()), "build", str(ROOT / "tests" / entry),
*flags, "-o", str(binary)], check=True, env=env, timeout=compile_timeout)
subprocess.run([str(binary)], check=True, timeout=30)
print("PASS 3D Base and Luce consumers, native and comparison modes")