Enhance run_tests.sh to allow running single tests and skipping preparation
This commit is contained in:
parent
556aaf3330
commit
a69afe4cd7
6
Makefile
6
Makefile
@ -8,4 +8,8 @@ config/environments/test.js: config/environments/test.js.example
|
|||||||
./configure
|
./configure
|
||||||
|
|
||||||
check: config/environments/test.js
|
check: config/environments/test.js
|
||||||
./run_tests.sh
|
./run_tests.sh ${RUNTESTFLAGS} \
|
||||||
|
test/unit/cartodb/redis_pool.test.js \
|
||||||
|
test/unit/cartodb/req2params.test.js \
|
||||||
|
test/acceptance/cache_validator.js \
|
||||||
|
test/acceptance/server.js
|
||||||
|
1
NEWS.md
1
NEWS.md
@ -1,5 +1,6 @@
|
|||||||
1.1.5 (DD//MM//YY)
|
1.1.5 (DD//MM//YY)
|
||||||
-----
|
-----
|
||||||
|
* Enhance run_tests.sh to allow running single tests and skipping preparation
|
||||||
|
|
||||||
1.1.4 (DD//MM//YY)
|
1.1.4 (DD//MM//YY)
|
||||||
-----
|
-----
|
||||||
|
67
run_tests.sh
67
run_tests.sh
@ -1,11 +1,28 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Must match config.redis_pool.port in test/support/config.js
|
# Must match redis_port in config/environments/test.js
|
||||||
|
# TODO: read from there
|
||||||
REDIS_PORT=6333
|
REDIS_PORT=6333
|
||||||
|
|
||||||
|
OPT_CREATE=yes # create the test environment
|
||||||
|
OPT_DROP=yes # drop the test environment
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
BASEDIR=$(pwd)
|
||||||
|
cd -
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
echo "Cleaning up"
|
if test x"$OPT_DROP" = xyes; then
|
||||||
kill ${PID_REDIS}
|
if test x"$PID_REDIS" = x; then
|
||||||
|
PID_REDIS=$(cat ${BASEDIR}/redis.pid)
|
||||||
|
if test x"$PID_REDIS" = x; then
|
||||||
|
echo "Could not find a test redis pid to kill it"
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Cleaning up"
|
||||||
|
kill ${PID_REDIS}
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_and_exit() {
|
cleanup_and_exit() {
|
||||||
@ -22,21 +39,43 @@ die() {
|
|||||||
|
|
||||||
trap 'cleanup_and_exit' 1 2 3 5 9 13
|
trap 'cleanup_and_exit' 1 2 3 5 9 13
|
||||||
|
|
||||||
echo "Starting redis on port ${REDIS_PORT}"
|
while [ -n "$1" ]; do
|
||||||
echo "port ${REDIS_PORT}" | redis-server - > test.log &
|
if test "$1" = "--nodrop"; then
|
||||||
PID_REDIS=$!
|
OPT_DROP=no
|
||||||
|
shift
|
||||||
|
continue
|
||||||
|
elif test "$1" = "--nocreate"; then
|
||||||
|
OPT_CREATE=no
|
||||||
|
shift
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Preparing the database"
|
if [ -z "$1" ]; then
|
||||||
cd test/support; sh prepare_db.sh >> test.log || die "database preparation failure (see test.log)"; cd -;
|
echo "Usage: $0 [<options>] <test> [<test>]" >&2
|
||||||
|
echo "Options:" >&2
|
||||||
|
echo " --nocreate do not create the test environment on start" >&2
|
||||||
|
echo " --nodrop do not drop the test environment on exit" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TESTS=$@
|
||||||
|
|
||||||
|
if test x"$OPT_CREATE" = xyes; then
|
||||||
|
echo "Starting redis on port ${REDIS_PORT}"
|
||||||
|
echo "port ${REDIS_PORT}" | redis-server - > ${BASEDIR}/test.log &
|
||||||
|
PID_REDIS=$!
|
||||||
|
echo ${PID_REDIS} > ${BASEDIR}/redis.pid
|
||||||
|
|
||||||
|
echo "Preparing the environment"
|
||||||
|
cd ${BASEDIR}/test/support; sh prepare_db.sh || die "database preparation failure"; cd -
|
||||||
|
fi
|
||||||
|
|
||||||
PATH=node_modules/.bin/:$PATH
|
PATH=node_modules/.bin/:$PATH
|
||||||
|
|
||||||
echo "Running tests"
|
echo "Running tests"
|
||||||
mocha -u tdd \
|
mocha -u tdd ${TESTS}
|
||||||
test/unit/cartodb/redis_pool.test.js \
|
|
||||||
test/unit/cartodb/req2params.test.js \
|
|
||||||
test/acceptance/cache_validator.js \
|
|
||||||
test/acceptance/server.js
|
|
||||||
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user