#!/bin/bash
set -e
if command -v python3 &> /dev/null; then
python_command=python3
else
python_command=python
fi
current_directory=$(dirname "$(readlink -f "$0")")
${python_command} -m coverage run --rcfile ${current_directory}/../.coveragerc ${current_directory}/UT/run.py 2>&1 | tee ${current_directory}/UT/run_UT.log
${python_command} -m coverage report --rcfile ${current_directory}/../.coveragerc
${python_command} -m coverage xml --rcfile ${current_directory}/../.coveragerc -o ${current_directory}/UT/coverage.xml
${python_command} -m coverage html --rcfile ${current_directory}/../.coveragerc -d ${current_directory}/UT/htmlcov
${python_command} ${current_directory}/scripts/unittest_summary.py ${current_directory}/UT/run_UT.log
pytest ${current_directory}/UT --junit-xml=${current_directory}/UT/final.xml