#!/bin/bash
# Runs trashcli's unit tests under Python 2.7.
#
# Uses a virtualenv hosted directly by pyenv's Python 2.7 (see
# lib/ensure-venv) instead of tox: tox 4 dropped the ability to drive
# legacy interpreters, and modern virtualenv can't be used to *target*
# python2.7 from a Python 3 host either. Running pip/virtualenv under
# python2.7 itself sidesteps both problems -- the same approach CI uses
# (.github/workflows/run-tests.yml runs pytest natively per interpreter,
# no tox involved).
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIR="$(cd -- "$SCRIPT_DIR/../.." &> /dev/null && pwd )"
set -euo pipefail

VENV_DIR="$("$SCRIPT_DIR/lib/ensure-venv" .venv-py27)"

cd "$ROOT_DIR"
"$VENV_DIR/bin/pip" install --quiet -e . -e ".[dev]"
"$VENV_DIR/bin/python" -m pytest "$@"
