dymokomi/luc
Source of release 0.24.2
0.24.2 / tests / registry / main.luc
# luc against registries, servers and Git that Python stands up beside it: anonymous
# packages (add, lock, sync, offline use, tamper refusal, installs), remote refs, sessions,
# registration, fetch and checkout. Each check is a script here that serves the fixtures
# over loopback HTTP and drives a luc built from this checkout; stock Git builds the
# fixtures, so the oracles are independent of luc's own Git code.
from luce_std import files, paths, process
let failed = ErrorCode.package(1)
pub func main(arguments: list[str]) -> int!:
let top = process.current_directory()
let here = process.variable("LUC_TEST_DIR") else error(failed, "LUC_TEST_DIR names no directory")
let base = process.variable("LUCE_BASE") else error(failed, "LUCE_BASE names no compiler")
let work = paths.join(top, "build/tests/registry/work")
files.ensure_directory(work)
let luc = paths.join(work, "luc")
let built = process.run(base, ["build", paths.join(top, "src/main.lucb"), "--native", "-o", luc], top)
if built.exit_code != 0:
error(failed, f"build luc: {built.output}{built.error_output}")
var failures = 0
# Not run on Windows yet: register.py types the password at a terminal it makes with
# `pty`, which Windows has not; packages.py and session.py fail there today (a luc.lock
# read back as "malformed digest or commit"; a failed login, and a session file whose
# 0600 mode Windows does not keep), luc's own gaps to close.
let windows = (process.variable("OS") else "") == "Windows_NT"
for script in ["packages.py", "remote.py", "session.py", "register.py", "fetch.py", "checkout.py"]:
if windows and (script == "register.py" or script == "packages.py" or script == "session.py"):
print(f"{script}: not run on Windows")
continue
var words = [script, luc]
if script == "checkout.py":
words.append(base)
let ran = process.run("python3", words, here)
if ran.exit_code == 0:
print(ran.output.trim_end().split("\n")[-1])
else:
print(f"FAIL {script}: exit status {ran.exit_code}\n{ran.output}{ran.error_output}")
failures += 1
return 1 if failures > 0 else 0