Skip to content
Snippets Groups Projects
Commit 9d2834f0 authored by Ambrus Simon's avatar Ambrus Simon
Browse files

Add --no-abao, --no-report and review fixes

parent cdcb1085
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,11 @@ Run automated tests:
* To skip linting, use `--no-lint` (`-L`)
* To skip unit tests, use `--no-unit` (`-U`)
* To skip integration tests, use `--no-integ` (`-I`)
* To skip abao tests, use `--no-abao` (`-A`)
* To pass any arguments to `py.test`, use `-- PYTEST_ARGS`
See [py.test usage](https://docs.pytest.org/en/latest/usage.html) for more.
### Docker
Build scitran-core image and run automated tests in a docker container:
```
......@@ -22,9 +25,9 @@ Build scitran-core image and run automated tests in a docker container:
* To pass any arguments to `run-tests-ubuntu.sh`, use `-- TEST_ARGS`
#### Example
Without rebuilding the image, run only unit tests matching `foo`, use the highest verbosity level for test output and jump into a python debugger session in case an assertion fails:
Without rebuilding the image, run only integration tests matching `foo`, use the highest verbosity level for test output and jump into a python debugger session in case an assertion fails:
```
./test/bin/run-tests-docker.sh -B -- -L -I -- -k foo -vvv --pdb
./test/bin/run-tests-docker.sh -B -- -L -U -A -- -k foo -vvv --pdb
```
### Tools
......
......@@ -34,6 +34,8 @@ function main() {
shift
done
trap clean_up EXIT
if ${DOCKER_BUILD}; then
echo "Building scitran-core:run-tests ..."
docker build -t scitran-core:run-tests .
......@@ -62,7 +64,7 @@ function main() {
function clean_up() {
export TEST_RESULT_CODE=$?
local TEST_RESULT_CODE=$?
set +e
# Copy coverage file to host for possible further reporting
......@@ -75,7 +77,5 @@ function clean_up() {
exit $TEST_RESULT_CODE
}
trap clean_up EXIT
main "$@"
......@@ -15,6 +15,8 @@ Options:
-L, --no-lint Skip linting
-U, --no-unit Skip unit tests
-I, --no-integ Skip integration tests
-A, --no-abao Skip abao tests
-R, --no-report Skip coverage report
-h, --help Print this help and exit
-- PYTEST_ARGS Arguments passed to py.test
......@@ -34,13 +36,18 @@ function main() {
local RUN_LINT=true
local RUN_UNIT=true
local RUN_INTEG=true
local RUN_ABAO=true
local PYTEST_ARGS=
export RUN_REPORT=true
while [[ "$#" > 0 ]]; do
case "$1" in
-L|--no-lint) RUN_LINT=false ;;
-U|--no-unit) RUN_UNIT=false ;;
-I|--no-integ) RUN_INTEG=false ;;
-L|--no-lint) RUN_LINT=false ;;
-U|--no-unit) RUN_UNIT=false ;;
-I|--no-integ) RUN_INTEG=false ;;
-A|--no-abao) RUN_ABAO=false ;;
-R|--no-report) RUN_REPORT=false ;;
-h|--help) usage; exit 0 ;;
--) PYTEST_ARGS="${@:2}"; break ;;
*) echo "Invalid argument: $1" >&2; usage; exit 1 ;;
......@@ -48,6 +55,13 @@ function main() {
shift
done
if ! (${RUN_LINT} && ${RUN_UNIT} && ${RUN_INTEG} && ${RUN_ABAO}); then
# Skip coverage report if any tests are skipped
RUN_REPORT=false
fi
trap clean_up EXIT
# Remove __pycache__ directories for issue with __file__ attribute due to
# running the tests on the host creating bytecode files hich have a
# mismatched __file__ attribute when loaded in docker container
......@@ -79,8 +93,8 @@ function main() {
py.test --cov=api --cov-report= test/unit_tests/python $PYTEST_ARGS
fi
if ${RUN_INTEG}; then
echo "Running integration tests ..."
if ${RUN_INTEG} || ${RUN_ABAO}; then
echo "Spinning up dependencies ..."
uwsgi --http "localhost:8081" --master --http-keepalive \
--so-keepalive --add-header "Connection: Keep-Alive" \
--processes 1 --threads 1 \
......@@ -102,10 +116,15 @@ function main() {
printf '.'
sleep 1
done
fi
if ${RUN_INTEG}; then
echo "Running integration tests ..."
py.test test/integration_tests/python $PYTEST_ARGS
fi
if ${RUN_ABAO}; then
echo "Running abao tests ..."
# Create resources that Abao relies on
python test/integration_tests/abao/load_fixture.py
......@@ -133,7 +152,7 @@ function main() {
function clean_up () {
export TEST_RESULT_CODE=$?
local TEST_RESULT_CODE=$?
set +e
echo
......@@ -141,11 +160,11 @@ function clean_up () {
if [[ -n "${API_PID:-}" ]]; then
# Killing uwsgi
kill $API_PID || true
kill $API_PID
wait 2> /dev/null
fi
if [[ "${TEST_RESULT_CODE}" == "0" ]]; then
if ${RUN_REPORT} && [[ "${TEST_RESULT_CODE}" == "0" ]]; then
echo
echo "UNIT TEST COVERAGE:"
coverage report --skip-covered
......@@ -154,12 +173,12 @@ function clean_up () {
coverage combine
coverage report --show-missing
coverage html
else
echo "Some tests were skipped or failed, skipping coverage report"
fi
exit $TEST_RESULT_CODE
}
trap clean_up EXIT
main "$@"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment