summaryrefslogtreecommitdiffstats
path: root/run-tests.sh
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-05-21 15:11:36 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-21 18:43:13 +0200
commit764ec006839636a5dc7bd6bf65760037570a16c0 (patch)
treee99f89a35a967db607008c07807bca71acd06127 /run-tests.sh
parent77198abd94437eb418f11957695986470b1afc9a (diff)
tests: Rework database handling
We no longer interfere with the normal installation's database settings. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'run-tests.sh')
-rwxr-xr-xrun-tests.sh57
1 files changed, 23 insertions, 34 deletions
diff --git a/run-tests.sh b/run-tests.sh
index 5d1c2597c..78e36d3c9 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -2,56 +2,45 @@
#
# This runs the testsuite
#
-# If you have a local webserver you can call this script with it's URL.
+
+export ENVIRONMENT="testsuite"
startdir="$(dirname "$0")"
url=""
-use_php_dev_server=0
-
-if (($#>0)); then
- url="$1"
-fi
-
+port=23115
+ip='127.0.0.1'
+url="http://$ip:$port/index.php"
+
+die() {
+ echo "$@" >&2
+ echo "Aborting..." >&2
+ exit 1
+}
-if [[ -z "$url" ]]; then
- port=23115
- url="http://127.0.0.1:$port/index.php"
- use_php_dev_server=1
-fi
cd "$startdir"
-test -d system || exit 1
-test -d application || exit 1
-test -f run-tests.sh || exit 1
+# some sanity checks
+test -d system || die 'Required dir not found.'
+test -d application || die 'Required dir not found.'
+test -f run-tests.sh || die 'Required file not found.'
+grep -qF 'getenv("ENVIRONMENT")' application/config/database.php || die "database config doesn't honor ENVIRONMENT."
# prepare
trap cleanup EXIT INT
cleanup() {
- php index.php tools drop_all_tables_using_prefix
- if ((use_php_dev_server)); then
- kill $server_pid
- fi
- rm -f $startdir/application/config/database-testsuite.php
+ pkill -P $$
+ php index.php tools drop_all_tables
}
-cat <<EOF >application/config/database-testsuite.php || exit 1
-<?php
-\$db['default']['dbprefix'] = "testsuite-prefix-";
-EOF
-
-if ((use_php_dev_server)); then
- php -S 127.0.0.1:$port &
- server_pid=$!
-
- while ! curl -s "$url" >/dev/null; do
- sleep 0.2;
- done
-fi
+php -S "$ip:$port" &
+while ! curl -s "$url" >/dev/null; do
+ sleep 0.1;
+done
# run tests
-php index.php tools drop_all_tables_using_prefix
+php index.php tools drop_all_tables
php index.php tools update_database
prove --ext .php --state=hot,slow,all,save --timer -ve "php index.php tools test $url" -r application/test/tests/