tooz/setup-postgresql-env.sh
Julien Danjou e153202ca0 tests: remove check_port
It's not portable and currently the detection scheme use really easy to
break and report false positive. Try to rather launch services on
different ports.

Change-Id: I0739bea2f8fe42e1bba1c04e6ce5be14237dfbcb
2014-12-01 15:00:47 +01:00

24 lines
662 B
Bash
Executable File

#!/bin/bash
set -x -e
function clean_exit() {
local error_code="$?"
${PGSQL_PATH}/pg_ctl -w -D ${PGSQL_DATA} -o "-p $PGSQL_PORT" stop
rm -rf ${PGSQL_DATA}
return $error_code
}
trap "clean_exit" EXIT
# Start PostgreSQL process for tests
PGSQL_DATA=`mktemp -d /tmp/tooz-pgsql-XXXXX`
PGSQL_PATH=`pg_config --bindir`
PGSQL_PORT=9825
${PGSQL_PATH}/initdb ${PGSQL_DATA}
${PGSQL_PATH}/pg_ctl -w -D ${PGSQL_DATA} -o "-k ${PGSQL_DATA} -p ${PGSQL_PORT}" start
# Wait for PostgreSQL to start listening to connections
export TOOZ_TEST_PGSQL_URL="postgresql:///?host=${PGSQL_DATA}&port=${PGSQL_PORT}&dbname=template1"
# Yield execution to venv command
$*