From 497b3b578b5e9367d9f514879104a66deb87fc4c Mon Sep 17 00:00:00 2001 From: Lukas Braun <lukas.braun@fau.de> Date: Sat, 7 Oct 2017 14:09:29 +0200 Subject: [PATCH] Only start Postgres for tests when requested --- Makefile | 2 +- test_pg.sh | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 3a1ecb6..d8d63ff 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ goatherd: goatherd.go go build goatherd.go test_pg: goatherd.go goatherd_test.go test_pg.sh goatherd - sh test_pg.sh + sh test_pg.sh --start-pg test_pam_goatherd: goatherd pam_goatherd.so test_pam_goatherd.sh sh test_pam_goatherd.sh diff --git a/test_pg.sh b/test_pg.sh index e8836e2..c4fdadb 100644 --- a/test_pg.sh +++ b/test_pg.sh @@ -4,17 +4,21 @@ set -eu go test -c -o ./goatherd.test & -PGHOST="$PWD/postgres_test" -if [ $# -ge 1 ]; then - PGHOST="$(realpath -- "$1")" - shift -fi -export PGHOST="$PGHOST" +if [ "${1:-x}" = "--start-pg" ]; then + PGHOST="$PWD/postgres_test" + if [ $# -ge 1 ]; then + PGHOST="$(realpath -- "$1")" + shift + fi + export PGHOST="$PGHOST" -. ./start_pg.sh -trap 'start_pg_cleanup' EXIT INT + . ./start_pg.sh + trap 'start_pg_cleanup' EXIT INT -createdb goatherd_test + createdb goatherd_test + + export DB_URL="host=$PGHOST dbname=goatherd_test" +fi echo Waiting for compile to finish wait %1 @@ -22,13 +26,13 @@ wait %1 echo echo ===== Go Tests ===== -DB_URL="host=$PGHOST dbname=goatherd_test" ./goatherd.test "$@" +./goatherd.test "$@" echo ===== Command-Line Tests ===== gh() { - ./goatherd -config "$PWD/pam_goatherd_test.conf" -db-url "host=$PGHOST dbname=goatherd_test" "$@" + ./goatherd -config "$PWD/pam_goatherd_test.conf" -db-url "$DB_URL" "$@" } expecting() { -- GitLab