mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 03:38:23 +00:00
`make test-unit` (docker runner) reached run.sh inside the container via `bash --login`, which never sources the project's env-loader. PYTHON stayed unset, so the test invocation fell back to the system python3 — which has none of the runtime deps (ruamel, ansible, bcrypt, requests, certifi, humanfriendly), producing 132+ ModuleNotFoundError errors. run.sh now sources scripts/meta/env/load.sh itself (idempotent via INFINITO_ENV_LOADED), so the env layer applies regardless of how the shell was spawned. While load.sh's detect.sh (now scripts/meta/env/python.sh) correctly walks /opt/venvs and ~/.venvs to find the venv, an ambient VIRTUAL_ENV from a different project (e.g. /root/.venvs/pkgmgr in pkgmgr's container) would hijack the resolution. python.sh now scans the project-named venv candidates first and only falls back to VIRTUAL_ENV when no project venv exists. Also moves scripts/meta/python/detect.sh to scripts/meta/env/python.sh so the env-related helpers live under one directory; updates the load.sh source pragma and the lint-test path that scans it for INFINITO_* registrations. `make test-unit` goes from 1262 tests / 132 errors to 1999 tests / 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
Bash
Executable File
35 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs the actual unittest discover invocation for the test suite picked
|
|
# by INFINITO_TEST_TYPE / INFINITO_TEST_PATTERN. Invoked either directly on the host or
|
|
# inside the infinito compose container by scripts/tests/code/wrapper.sh
|
|
# -- the body is identical for both runners.
|
|
set -euo pipefail
|
|
|
|
_run_sh_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source "${_run_sh_dir}/../../meta/env/load.sh"
|
|
unset _run_sh_dir
|
|
|
|
: "${INFINITO_TEST_PATTERN:?INFINITO_TEST_PATTERN must be set}"
|
|
: "${INFINITO_TEST_TYPE:?INFINITO_TEST_TYPE must be set}" # nocheck: makefile-supplied
|
|
|
|
NIX_CONFIG_EFFECTIVE="$(
|
|
printf "%s\n%s\n" \
|
|
"${NIX_CONFIG:-}" \
|
|
"accept-flake-config = true" |
|
|
sed -e "s/[[:space:]]\+$//" -e "/^$/d" |
|
|
awk '!seen[$0]++'
|
|
)"
|
|
export NIX_CONFIG="${NIX_CONFIG_EFFECTIVE}"
|
|
|
|
echo "PWD=$(pwd)"
|
|
echo "PYTHON=${PYTHON:-<unset>}"
|
|
|
|
if [ -n "${PYTHON:-}" ]; then
|
|
PATH="$(dirname "$PYTHON"):$PATH"
|
|
export PATH
|
|
fi
|
|
|
|
make setup
|
|
"${PYTHON:-python3}" -m unittest discover -s "tests/${INFINITO_TEST_TYPE}" -t . -p "${INFINITO_TEST_PATTERN}" # nocheck: makefile-supplied
|