#!/bin/bash

set -euo pipefail
# Can't run in parralel because of the shared docker
# instance.

# if venv doesn't exist, invoke ./install
if [ ! -d ".venv" ]; then
    echo "No venv present, so installing..."
    ./install
fi

. ./activate

# --full in args, then rebuild the docker image
if [[ "$*" == *"--full"* ]]; then
    echo "Rebuilding docker image"
    echo "Rebuilding from local image"
    uv run build_local_docker.py
fi

# If the test fails, then purge and try again
pytest -x -v -s --durations=0 tests/unit "$@"

# uv run pytest -n auto tests -v

