#!/usr/bin/env bash

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"

PYTHON_BIN="${FFX_PYTHON:-${HOME}/.local/share/ffx.venv/bin/python}"

if [[ ! -x "${PYTHON_BIN}" ]]; then
    echo "Missing Python interpreter: ${PYTHON_BIN}" >&2
    echo "Set FFX_PYTHON to a suitable interpreter if needed." >&2
    exit 1
fi

cd "${REPO_ROOT}"

exec "${PYTHON_BIN}" -m pytest \
    --ignore=tests/legacy \
    --ignore=tests/support \
    tests \
    "$@"
