Files
testium/scripts/build_env.sh
François 8bd9b3e9d6 Add plugin registry for report exporters
Replace the hardcoded if/elif in Export.exec() with a dict registry.
Built-in formats (text, json, junit, html) are registered as lazy
loaders; missing optional deps (junit_xml, lxml) print a clear message
with a pip install hint instead of raising. Entry-points
(group "testium.exporters") are discovered at import time — installed
plugins are auto-detected with no extra config.

An unknown or unavailable format prints an info line and skips the
export; the test run is not interrupted.

Validation:
- New testium-fake-exporter package under test/validation/fake_exporter/
  installed automatically by scripts/build_env.sh on venv creation.
  It registers fake_format via entry-points and exports the tests
  table to CSV — a real, useful exporter that exercises the plugin
  contract end-to-end (entry-point discovery, dispatch, SQLite query).
- New dedicated items/report_plugin/ test exercises both the
  unknown-format skip path and the fake_format plugin path, with a
  py_func check (file_check.py) on the produced CSV. Runs once per
  validation suite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 23:16:10 +02:00

37 lines
943 B
Bash
Executable File

#!/bin/bash
if [ -z $PY_VENV_DIR ]; then
echo "PY_VENV_DIR must be defined"
exit -1
fi
if [ -z $REQ_PATH ]; then
echo "REQ_PATH must be defined"
exit -1
fi
if [ "$1" == "clean" ]; then
rm -Rf "$PY_VENV_DIR"
fi
# Check if venv is installed
python3 -c "import venv"
if [ "$?" -ne 0 ]; then
echo "venv must be installed on the host distribution."
exit -1
fi
# Install the virtual environment if needed
if [ ! -d "$PY_VENV_DIR" ]; then
echo "Creation of the virtual environment"
python3 -m venv "$PY_VENV_DIR"
source "$PY_VENV_DIR/bin/activate"
pip install --extra-index-url https://pypi.python.org/pypi -r $REQ_PATH
# Validation suite plugin used to verify the report-exporter
# entry-points discovery end-to-end.
FAKE_EXPORTER_DIR="$(dirname "$REQ_PATH")/../test/validation/fake_exporter"
if [ -d "$FAKE_EXPORTER_DIR" ]; then
pip install -e "$FAKE_EXPORTER_DIR"
fi
fi