Skip to content

inner

inner

Generate the scripts that run inside a slot's test container.

Two scripts per slot, both written to the shared results mount so the container executes real files — the historical bash -c string with its three levels of quote-escaping is gone:

  • the outer script runs as root: copy the read-only source mount into a writable workspace, prove the init system matches the slot's contract, then drop to the slot's test user;
  • the inner script runs as the test user: export the capability contract, bootstrap a Python 3.12 venv plus uv, sync the repo's locked dependency groups, and walk the configured phases.

Command phases abort the slot on failure (set -e); pytest phases record the first failing exit code and keep going, so a single run surfaces every failing suite.

TEST_UID = 1000 module-attribute

outer_script(config, slot_name)

Root-side container entry: workspace prep, init-system proof, user drop.

Source code in src/terok_util/matrix/inner.py
def outer_script(config: MatrixConfig, slot_name: str) -> str:
    """Root-side container entry: workspace prep, init-system proof, user drop."""
    spec = SLOTS[slot_name]
    lines = [
        "#!/bin/bash",
        "set -e -o pipefail",
        "",
        f"cp -a {SOURCE_MOUNT} {WORKSPACE_DIR}",
        f"chown -R {spec.user}:{spec.user} {WORKSPACE_DIR}",
    ]
    if spec.kind is SlotKind.CONTAINER:
        lines += _init_system_proof(slot_name)
    if config.flavor == "podman" and spec.kind is SlotKind.CONTAINER:
        lines += _resolv_conf_strip()
    lines += [
        "",
        f"install -m 0755 {RESULTS_MOUNT}/inner-{slot_name}.sh /tmp/inner.sh",
        *_user_drop(spec.user, spec.kind),
        "",
    ]
    return "\n".join(lines)

inner_script(config, slot_name, scope='all')

Test-user-side flow: env contract, venv + deps, configured phases.

Source code in src/terok_util/matrix/inner.py
def inner_script(config: MatrixConfig, slot_name: str, scope: str = "all") -> str:
    """Test-user-side flow: env contract, venv + deps, configured phases."""
    spec = SLOTS[slot_name]
    lines = ["#!/bin/bash", "set -e -o pipefail", ""]
    if spec.kind is SlotKind.CONTAINER:
        lines += ["export XDG_RUNTIME_DIR=/run/user/$(id -u)"]
    lines += _env_contract(config, slot_name)
    lines += ["", f"cd {WORKSPACE_DIR}", ""]
    if spec.kind is SlotKind.NIX:
        lines += _nix_python_report(slot_name)
        lines += _plain_venv_bootstrap(f"python{PYTHON_VERSION}")
    else:
        if config.flavor == "podman":
            lines += _podman_report_and_preflight(slot_name)
        lines += _uv_or_venv_bootstrap()
    lines += _uv_sync(config.slot_groups(slot_name))
    lines += _phase_walk(config, slot_name, scope)
    return "\n".join(lines) + "\n"