dev.sh: support running only integration tests or haskell/unit tests individually

This commit is contained in:
Brandon Simmons 2019-11-14 13:33:30 -05:00
parent 256be84dba
commit 505ea4deef

View File

@ -34,10 +34,12 @@ Available COMMANDs:
Launch a postgres container suitable for use with graphql-engine, watch its logs,
clean up nicely after
test [pytest_args...]
Run the integration tests, handling spinning up all dependencies. This will force
a recompile. A code coverage report will be generated. All arguments after 'test'
will be passed to the 'pytest' invocation.
test [--integration [pytest_args...] | --unit]
Run the unit and integration tests, handling spinning up all dependencies.
This will force a recompile. A code coverage report will be generated.
Either integration or unit tests can be run individually with their
respective flags. With '--integration' any arguments that follow will be
passed to the pytest invocation
EOL
exit 1
@ -64,7 +66,24 @@ case "${1-}" in
postgres)
;;
test)
PYTEST_ARGS="${@:2}"
case "${2-}" in
--unit)
RUN_INTEGRATION_TESTS=false
RUN_UNIT_TESTS=true
;;
--integration)
PYTEST_ARGS="${@:3}"
RUN_INTEGRATION_TESTS=true
RUN_UNIT_TESTS=false
;;
"")
RUN_INTEGRATION_TESTS=true
RUN_UNIT_TESTS=true
;;
*)
die_usage
;;
esac
;;
*)
die_usage
@ -312,9 +331,13 @@ elif [ "$MODE" = "test" ]; then
launch_postgres_container
wait_docker_postgres
# These also depend on a running DB:
if [ "$RUN_UNIT_TESTS" = true ]; then
echo_pretty "Running Haskell test suite"
HASURA_GRAPHQL_DATABASE_URL="$DB_URL" $TEST_INVOCATION --coverage
fi
if [ "$RUN_INTEGRATION_TESTS" = true ]; then
echo_pretty "Starting graphql-engine"
GRAPHQL_ENGINE_TEST_LOG=/tmp/hasura-dev-test-engine.log
export HASURA_GRAPHQL_SERVER_PORT=8088
@ -380,6 +403,7 @@ elif [ "$MODE" = "test" ]; then
echo
stack hpc report graphql-engine.tix
rm graphql-engine.tix
fi
else
echo "impossible; fix script."