#!/bin/sh -eu

cd "$RUN_DIR"

dbfile="${UNWIND_DATA:-./data}/tests.sqlite"

# Rollback in Databases is currently broken, so we have to rebuild the database
# each time; see https://github.com/encode/databases/issues/403
trap 'rm "$dbfile" "${dbfile}-shm" "${dbfile}-wal"' EXIT TERM INT QUIT

[ -z "${DEBUG:-}" ] || set -x

UNWIND_STORAGE="$dbfile" \
    exec poetry run pytest --cov "$@"
