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
|
||||
|
||||
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)
|
||||
-----
|
||||
* Enhance run_tests.sh to allow running single tests and skipping preparation
|
||||
|
||||
1.1.4 (DD//MM//YY)
|
||||
-----
|
||||
|
67
run_tests.sh
67
run_tests.sh
@ -1,11 +1,28 @@
|
||||
#!/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
|
||||
|
||||
OPT_CREATE=yes # create the test environment
|
||||
OPT_DROP=yes # drop the test environment
|
||||
|
||||
cd $(dirname $0)
|
||||
BASEDIR=$(pwd)
|
||||
cd -
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up"
|
||||
kill ${PID_REDIS}
|
||||
if test x"$OPT_DROP" = xyes; then
|
||||
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() {
|
||||
@ -22,21 +39,43 @@ die() {
|
||||
|
||||
trap 'cleanup_and_exit' 1 2 3 5 9 13
|
||||
|
||||
echo "Starting redis on port ${REDIS_PORT}"
|
||||
echo "port ${REDIS_PORT}" | redis-server - > test.log &
|
||||
PID_REDIS=$!
|
||||
while [ -n "$1" ]; do
|
||||
if test "$1" = "--nodrop"; then
|
||||
OPT_DROP=no
|
||||
shift
|
||||
continue
|
||||
elif test "$1" = "--nocreate"; then
|
||||
OPT_CREATE=no
|
||||
shift
|
||||
continue
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Preparing the database"
|
||||
cd test/support; sh prepare_db.sh >> test.log || die "database preparation failure (see test.log)"; cd -;
|
||||
if [ -z "$1" ]; then
|
||||
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
|
||||
|
||||
echo "Running tests"
|
||||
mocha -u tdd \
|
||||
test/unit/cartodb/redis_pool.test.js \
|
||||
test/unit/cartodb/req2params.test.js \
|
||||
test/acceptance/cache_validator.js \
|
||||
test/acceptance/server.js
|
||||
|
||||
mocha -u tdd ${TESTS}
|
||||
|
||||
cleanup
|
||||
|
Loading…
Reference in New Issue
Block a user