#!/usr/bin/env bash
#MISE depends=["build"]
#MISE alias="e"
#MISE description="run end-to-end tests"
set -euo pipefail

export RUST_TEST_THREADS=1

if [[ "${1:-all}" == all ]]; then
  ./e2e/run_all_tests
else
  pushd e2e
  FILES="$(fd -tf "$1" --and "^test_")"
  popd
  if [[ -z $FILES ]]; then
    echo "Not test matches $1" >&2
    exit 1
  fi
  for FILE in $FILES; do
    ./e2e/run_test "$FILE"
  done
fi
