unittest/scripts/unittest.sh

48 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#
# Set commands depending on distribution
#
. /etc/os-release
# python2
if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
COV2_CMD="coverage2"
PYT2_CMD="python2"
else
COV2_CMD="python2-coverage"
PYT2_CMD="python2"
fi
# python3
if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
COV3_CMD="coverage3"
PYT3_CMD="python3"
else
COV3_CMD="python3-coverage"
PYT3_CMD="python3"
fi
# pdf viewer
PDF_CMD="xdg-open"
if [[ $# -eq 0 || ($# -eq 2 && $1 == '-e') ]]; then
#
# Unittest Flow
#
$PYT3_CMD unittest.py clean
echo -e "\e[1m * Erasing collected coverage information\e[0m"
$COV2_CMD erase
$COV2_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) unittest.py run $*
$COV3_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) unittest.py run $*
echo -e "\e[1m\e[93mCreating Coverage-XML-File: $(pwd)/testresults/coverage.xml\e[0m"
$COV3_CMD xml -o testresults/coverage.xml
$PYT3_CMD unittest.py finalise
$PYT3_CMD unittest.py status
$PYT3_CMD unittest.py pdf
$PDF_CMD testresults/unittest.pdf
else
$PYT3_CMD unittest.py $*
fi
exit 0