trainUs/tests/run_parallel.sh
David 352a3d5e88
Some checks are pending
CI / Lint & Format (push) Waiting to run
CI / Build (push) Waiting to run
CI / Tests (${{ matrix.browser }}) (chromium) (push) Waiting to run
CI / Tests (${{ matrix.browser }}) (firefox) (push) Waiting to run
Initial commit
2026-06-18 13:06:57 +02:00

36 lines
1,011 B
Bash
Executable file

#!/usr/bin/env bash
# Run the Playwright test suite in parallel using pytest-xdist.
#
# Usage:
# ./run_parallel.sh # both browsers, auto workers
# ./run_parallel.sh --browser firefox # override browser selection
# ./run_parallel.sh test_step3_exercises.py # single file, both browsers
#
# Environment variables:
# PYTEST_WORKERS number of parallel workers (default: auto = one per CPU core)
# PYTEST_BROWSERS space-separated list of browsers (default: "firefox chromium")
#
# Examples:
# PYTEST_WORKERS=4 ./run_parallel.sh
# PYTEST_WORKERS=2 PYTEST_BROWSERS="firefox" ./run_parallel.sh
set -euo pipefail
cd "$(dirname "$0")"
WORKERS="${PYTEST_WORKERS:-auto}"
BROWSERS="${PYTEST_BROWSERS:-firefox chromium}"
# Build --browser flags from the BROWSERS variable
BROWSER_FLAGS=()
for b in $BROWSERS; do
BROWSER_FLAGS+=(--browser "$b")
done
.venv/bin/python -m pytest \
"${BROWSER_FLAGS[@]}" \
--dist loadfile \
-n "$WORKERS" \
-v \
"$@"