2015-11-18 16:19:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# Run project tests
|
|
|
|
|
#
|
|
|
|
|
# NOTE: This script expects to be run from the project root with
|
|
|
|
|
# ./scripts/run_tests.sh
|
|
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
|
|
function display_result {
|
|
|
|
|
RESULT=$1
|
|
|
|
|
EXIT_STATUS=$2
|
|
|
|
|
TEST=$3
|
|
|
|
|
|
|
|
|
|
if [ $RESULT -ne 0 ]; then
|
|
|
|
|
echo -e "\033[31m$TEST failed\033[0m"
|
|
|
|
|
exit $EXIT_STATUS
|
|
|
|
|
else
|
|
|
|
|
echo -e "\033[32m$TEST passed\033[0m"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 15:32:12 +01:00
|
|
|
if [[ -z "$VIRTUAL_ENV" ]] && [[ -d venv ]]; then
|
2016-08-12 11:23:50 +01:00
|
|
|
source ./venv/bin/activate
|
|
|
|
|
fi
|
2017-04-25 17:02:06 +01:00
|
|
|
|
2018-07-10 15:16:14 +01:00
|
|
|
make test-requirements
|
|
|
|
|
display_result $? 1 "Requirements check"
|
|
|
|
|
|
2018-02-12 10:26:55 +00:00
|
|
|
flake8 .
|
2015-11-18 16:19:40 +00:00
|
|
|
display_result $? 1 "Code style check"
|
|
|
|
|
|
2018-02-20 11:22:17 +00:00
|
|
|
isort --check-only -rc ./app ./tests
|
|
|
|
|
display_result $? 2 "Import order check"
|
|
|
|
|
|
2016-02-08 11:05:07 +00:00
|
|
|
npm test
|
2019-09-25 16:09:36 +01:00
|
|
|
display_result $? 3 "Javascript tests have failed"
|
2016-02-08 11:05:07 +00:00
|
|
|
|
2015-11-18 16:19:40 +00:00
|
|
|
## Code coverage
|
2019-09-17 14:49:42 +01:00
|
|
|
py.test -n auto --maxfail=10 --cov=app --cov-report=term-missing tests/ --junitxml=test_results.xml --strict -p no:warnings
|
2018-02-20 11:22:17 +00:00
|
|
|
display_result $? 4 "Code coverage"
|