Skip to content

Commit

Permalink
tests: add pytest arguments to test script
Browse files Browse the repository at this point in the history
  • Loading branch information
kpsherva committed Jan 9, 2024
1 parent 6d71180 commit 5471737
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ if [ $# -eq 0 ]; then
exit 1
fi

# Check for arguments
# Note: "-k" would clash with "pytest"
keep_services=0
pytest_args=()
test_module=$1
shift;
for arg in $@; do
# from the CLI args, filter out some known values and forward the rest to "pytest"
# note: we don't use "getopts" here b/c of some limitations (e.g. long options),
# which means that we can't combine short options (e.g. "./run-tests -Kk pattern")
case ${arg} in
-K|--keep-services)
keep_services=1
;;
*)
pytest_args+=( ${arg} )
;;
esac
done

# Always bring down docker services
function cleanup() {
eval "$(docker-services-cli down --env)"
Expand All @@ -32,9 +52,6 @@ trap cleanup EXIT
python -m check_manifest
python -m sphinx.cmd.build -qnNW docs docs/_build/html
eval "$(docker-services-cli up --db ${DB:-postgresql} --search ${SEARCH:-opensearch2} --cache ${CACHE:-redis} --mq ${MQ:-rabbitmq} --env)"
if [ "${SEARCH}" = "opensearch2" ]; then
curl -XPUT localhost:9200/_cluster/settings -H "Content-Type:application/json" -d "{\"persistent\": {\"compatibility\": {\"override_main_response_version\": \"true\"}}}"
fi
python -m pytest tests/api/$1
python -m pytest tests/api/${test_module} ${pytest_args[@]+"${pytest_args[@]}"}
tests_exit_code=$?
exit "$tests_exit_code"

0 comments on commit 5471737

Please sign in to comment.