#!/bin/bash -eux

FLAG_P="FALSE"

while getopts p OPT
do
  case $OPT in
    "p" ) FLAG_P="TRUE" ;; # do performance test
      * ) echo "Usage: ./scripts/test [-p]" 1>&2
          exit 1 ;;
  esac
done

# create temporary directory for tests
mkdir -p test_data

# set flag
if [ "$FLAG_P" = "TRUE" ]; then
  TEST_PERFORMANCE="TRUE"
else
  TEST_PERFORMANCE="FALSE"
fi

# run tests
echo "Run unit tests"
TEST_PERFORMANCE=$TEST_PERFORMANCE \
KMP_DUPLICATE_LIB_OK='True' pytest --cov-report=xml \
       --cov=d3rlpy \
       --cov-config=.coveragerc \
       tests -p no:warnings -v

# clean up
rm -r test_data
