#!/bin/bash

set -e

# defaults if not set
: "${SKIP_LINT:=0}"
: "${COV_REPORT:=term}"
: "${COV_PORT:=8000}"

# convert to all lowercase
COV_REPORT=$(echo $COV_REPORT | tr '[:upper:]' '[:lower:]')

# run pytest with args set
echo 'Running tests...'
python -m pytest $TEST_ARGS tests/integration/ -v $COVERAGE_ARGS

# serve out html coverage report
if [ "$COV_REPORT" = "html" ]; then
    echo "Serving out coverage report on port $COV_PORT..."
    python -m http.server --directory htmlcov $COV_PORT
fi

echo 'Done!'
