atst/script/include/run_test
dandds beabd2ce72 Remove the scriptz submodule and hard-commit the files.
The submodule is a leftover from when this project was intended to work
as a series of microservices. It was meant to provide common
functionality to the builds for every microservice. That's no longer the
case, and the submodule is a pain-point both in on-boarding new
developers and running the Docker build.
2019-07-14 16:01:13 -04:00

50 lines
1.2 KiB
Plaintext

# run_test: Execute code checkers and unit tests
# Load test functions
source ./script/include/test_functions.inc.sh
## Set option defaults
# If PYTHON_FILES is not set, give it the default value of "app.py"
if [ -z "${PYTHON_FILES+is_set}" ]; then
PYTHON_FILES="app.py"
fi
# reset test database
if [ "${RESET_DB}" = "true" ]; then
# Fetch postgres settings and set them as ENV vars
source ./script/get_db_settings
if [ -n "${PGDATABASE}" ]; then
echo "Resetting database ${PGDATABASE}..."
# Reset the db
reset_db "${PGDATABASE}"
else
echo "ERROR: RESET_DB is set, but PGDATABASE is not!"
echo "Skipping database reset..."
fi
fi
## Main
if [ "${RUN_PYTHON_TESTS}" = "true" ]; then
python_test_status=0
set +e
run_python_lint "${PYTHON_FILES}"
((python_test_status+=$?))
run_python_static_analysis "${PYTHON_FILES}"
((python_test_status+=$?))
run_python_unit_tests "${PYTHON_FILES}"
((python_test_status+=$?))
if [ "${python_test_status}" != "0" ]; then
echo "Failed to pass one or more Python checks"
exit ${python_test_status}
fi
set -e
fi
if [ "${RUN_JS_TESTS}" = "true" ]; then
run_javascript_tests
fi