mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
Run the python suites through pytest-xdist when pytest is importable (id-level collection parity with unittest discover verified per suite; serial unittest stays the fallback), with -rP so warnings printed by passing tests, like the update annotations, still reach the log. run.sh self-provisions the dev extras through scripts/install/dev-extras.sh, which stamps inside the venv and skips read-only venvs; make onboard pre-warms the same path in the running container. Hoist per-test cache resets and roles scans to setUpClass in the lookup and resolvable suites (a per-test fingerprint-memo reset closes an id()-reuse cache-poisoning flake the hoist exposed), inject generation names into the nfs backup script test instead of sleeping, and narrow ansible-lint scope to real ansible content. ansible-lint additionally sits behind a content fingerprint gate that skips the run when nothing it walks has changed; without a usable git (container bind mounts) the gate disables itself and the full run remains. Drop the import-linter layer and ignore for the deleted deps module; the contract now locks compose -> common -> env. Measured on the host: unit 101s to 20s, integration 90s to 24s, lint tests 43s to 19s, repeated ansible-lint 53s to 0.4s. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.9 KiB
Bash
Executable File
45 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs the test suite picked by INFINITO_TEST_TYPE / INFINITO_TEST_PATTERN:
|
|
# parallel via pytest-xdist when pytest and xdist are importable, serial
|
|
# unittest discover otherwise. 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
|
|
|
|
echo "PWD=$(pwd)"
|
|
echo "PYTHON=${PYTHON:-<unset>}"
|
|
|
|
if [ -n "${PYTHON:-}" ]; then
|
|
PATH="$(dirname "$PYTHON"):$PATH"
|
|
export PATH
|
|
fi
|
|
|
|
make setup
|
|
bash "$(dirname "${BASH_SOURCE[0]}")/../../install/dev-extras.sh" || echo "dev extras install failed; running serial" >&2
|
|
_suite_dir="tests/${INFINITO_TEST_TYPE}" # nocheck: makefile-supplied
|
|
if "${PYTHON}" -c 'import pytest, xdist' >/dev/null 2>&1; then
|
|
# Exception: consider_namespace_packages + importlib import mode are
|
|
# required for hyphenated tests/unit/roles/<role>/ dirs; pytest's default
|
|
# identifier walk-up collapses every role's filter_plugins/files package
|
|
# onto one top-level name and cross-imports the wrong module.
|
|
# python_functions= pins collection to unittest-style TestCase methods,
|
|
# the exact set `unittest discover` runs. PYTHONDONTWRITEBYTECODE keeps
|
|
# namespace probing from dropping __pycache__ into roles/.
|
|
PYTHONDONTWRITEBYTECODE=1 "${PYTHON}" -m pytest "${_suite_dir}" -q -n auto -rP -p no:cacheprovider \
|
|
--import-mode=importlib \
|
|
-o consider_namespace_packages=true \
|
|
-o "norecursedirs=.* *.egg dist node_modules venv" \
|
|
-o python_functions= \
|
|
-o "python_files=${INFINITO_TEST_PATTERN}"
|
|
else
|
|
"${PYTHON}" -m unittest discover -s "${_suite_dir}" -t . -p "${INFINITO_TEST_PATTERN}"
|
|
fi
|