mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/backend/postgres/test/db-control.sh: rework to communicate
with postgres through a filesystem socket rather than a TCP connection so tests will work even on machines that don't allow TCP. This was a little tricky because shell substitutions were fighting the PG_CTL "-o '-k x -p y'" syntax. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6339 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8eee1e4d9d
commit
cf02d77d89
@ -1,33 +1,45 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
EXIT_VALUE=0
|
||||
|
||||
DB=$PWD/gnc_test
|
||||
DB=$PWD/gnc_test_db
|
||||
SOCKDIR=$PWD/gnc_test_db_sock
|
||||
SOCKNUM=7777
|
||||
|
||||
PG_CTL="pg_ctl -D $DB -o -p7777"
|
||||
# I couldn't get this to work -- the shell seems to think "'-k" is an
|
||||
# argument after it finishes expanding ${PG_CTL}...
|
||||
# PG_CTL="pg_ctl -D "${DB}" -o '-k ${SOCKDIR} -p ${SOCKNUM}'"
|
||||
|
||||
our_pg_ctl ()
|
||||
{
|
||||
pg_ctl -D "${DB}" -o "-k ${SOCKDIR} -p ${SOCKNUM}" "$@";
|
||||
}
|
||||
|
||||
case $1 in
|
||||
create)
|
||||
$PG_CTL status | grep "pid" && $PG_CTL stop && sleep 1
|
||||
rm -rf $DB
|
||||
initdb $DB || EXIT_VALUE=1
|
||||
our_pg_ctl status | grep "pid" && our_pg_ctl stop && sleep 1
|
||||
rm -rf ${DB}
|
||||
rm -rf ${SOCKDIR}
|
||||
initdb ${DB} || EXIT_VALUE=1
|
||||
mkdir ${SOCKDIR} || EXIT_VALUE=1
|
||||
;;
|
||||
destroy)
|
||||
$PG_CTL status | grep "pid" && $PG_CTL stop && sleep 1
|
||||
rm -rf $DB
|
||||
our_pg_ctl status | grep "pid" && our_pg_ctl stop && sleep 1
|
||||
rm -rf ${DB}
|
||||
rm -rf ${SOCKDIR}
|
||||
;;
|
||||
start)
|
||||
$PG_CTL start
|
||||
our_pg_ctl start
|
||||
;;
|
||||
stop)
|
||||
$PG_CTL stop
|
||||
pg_ctl -D ${DB} -o '-k ${SOCKDIR} -p 7777' stop
|
||||
;;
|
||||
status)
|
||||
$PG_CTL status
|
||||
our_pg_ctl status
|
||||
;;
|
||||
connect)
|
||||
$PG_CTL status | grep "not running" && $PG_CTL start && sleep 1
|
||||
psql -p 7777 $2
|
||||
our_pg_ctl status | grep "not running" && our_pg_ctl start && sleep 1
|
||||
psql -h ${SOCKDIR} -p ${SOCKNUM} $2
|
||||
;;
|
||||
*)
|
||||
echo "Bad command: $1"
|
||||
|
Loading…
Reference in New Issue
Block a user