Files
computer-playbook/scripts/tests/code.sh
T
kevinveenbirkenbach 5ce577bba2 refactor(tests): run unit tests directly via docker compose exec
- execute tests inside running infinito container (no CLI wrapper)
- require INFINITO_DISTRO explicitly and show it in banner
- keep Nix accept-flake-config behavior inside container
- pass TEST_PATTERN/TEST_TYPE as container env and set workdir
- fall back to python3 if PYTHON is unset

https://chatgpt.com/share/696ff1d0-aa84-800f-82cb-05f2b1618d05
2026-01-20 22:21:09 +01:00

40 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
echo "============================================================"
echo ">>> Running UNIT tests in ${INFINITO_DISTRO:-<unset>} container (compose stack)"
echo "============================================================"
: "${INFINITO_DISTRO:?INFINITO_DISTRO must be set}"
: "${TEST_PATTERN:?TEST_PATTERN must be set}"
: "${TEST_TYPE:?TEST_TYPE must be set}"
# Execute directly inside the already running infinito container
INFINITO_DISTRO="${INFINITO_DISTRO}" \
docker compose --profile ci exec -T \
-e TEST_PATTERN="${TEST_PATTERN}" \
-e TEST_TYPE="${TEST_TYPE}" \
--workdir /opt/src/infinito \
infinito \
bash -lc '
set -euo pipefail
NIX_CONFIG_EFFECTIVE="$(
printf "%s\n%s\n" \
"${NIX_CONFIG:-}" \
"accept-flake-config = true" \
| sed -e "s/[[:space:]]\+$//" -e "/^$/d"
)"
export NIX_CONFIG="${NIX_CONFIG_EFFECTIVE}"
echo "PWD=$(pwd)"
echo "PYTHON=${PYTHON:-<unset>}"
if [ -n "${PYTHON:-}" ]; then
export PATH="$(dirname "$PYTHON"):$PATH"
fi
make setup
"${PYTHON:-python3}" -m unittest discover -s "tests/${TEST_TYPE}" -t . -p "${TEST_PATTERN}"
'