Merge pull request #275 from CartoDB/coverage
Add option to generate coverage metrics using istanbul module
This commit is contained in:
commit
65c6559b1a
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ pids/
|
|||||||
redis.pid
|
redis.pid
|
||||||
test.log
|
test.log
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
coverage/
|
||||||
|
3
Makefile
3
Makefile
@ -33,6 +33,9 @@ jshint:
|
|||||||
|
|
||||||
test-all: jshint test
|
test-all: jshint test
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
@RUNTESTFLAGS=--with-coverage make test
|
||||||
|
|
||||||
check: test
|
check: test
|
||||||
|
|
||||||
.PHONY: pre-install test
|
.PHONY: pre-install test
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
"rollbar": "~0.3.13"
|
"rollbar": "~0.3.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"istanbul": "~0.3.6",
|
||||||
"mocha": "~1.21.4",
|
"mocha": "~1.21.4",
|
||||||
"jshint": "~2.6.0",
|
"jshint": "~2.6.0",
|
||||||
"redis": "~0.8.6",
|
"redis": "~0.8.6",
|
||||||
|
15
run_tests.sh
15
run_tests.sh
@ -4,6 +4,7 @@ OPT_CREATE_REDIS=yes # create the redis test environment
|
|||||||
OPT_CREATE_PGSQL=yes # create the PostgreSQL test environment
|
OPT_CREATE_PGSQL=yes # create the PostgreSQL test environment
|
||||||
OPT_DROP_REDIS=yes # drop the redis test environment
|
OPT_DROP_REDIS=yes # drop the redis test environment
|
||||||
OPT_DROP_PGSQL=yes # drop the PostgreSQL test environment
|
OPT_DROP_PGSQL=yes # drop the PostgreSQL test environment
|
||||||
|
OPT_COVERAGE=no # run tests with coverage
|
||||||
|
|
||||||
export PGAPPNAME=cartodb_tiler_tester
|
export PGAPPNAME=cartodb_tiler_tester
|
||||||
|
|
||||||
@ -69,6 +70,10 @@ while [ -n "$1" ]; do
|
|||||||
OPT_CREATE_REDIS=no
|
OPT_CREATE_REDIS=no
|
||||||
shift
|
shift
|
||||||
continue
|
continue
|
||||||
|
elif test "$1" = "--with-coverage"; then
|
||||||
|
OPT_COVERAGE=yes
|
||||||
|
shift
|
||||||
|
continue
|
||||||
# This is kept for backward compatibility
|
# This is kept for backward compatibility
|
||||||
elif test "$1" = "--nocreate"; then
|
elif test "$1" = "--nocreate"; then
|
||||||
OPT_CREATE_REDIS=no
|
OPT_CREATE_REDIS=no
|
||||||
@ -85,6 +90,7 @@ if [ -z "$1" ]; then
|
|||||||
echo "Options:" >&2
|
echo "Options:" >&2
|
||||||
echo " --nocreate do not create the test environment on start" >&2
|
echo " --nocreate do not create the test environment on start" >&2
|
||||||
echo " --nodrop do not drop the test environment on exit" >&2
|
echo " --nodrop do not drop the test environment on exit" >&2
|
||||||
|
echo " --with-coverage use istanbul to determine code coverage" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -112,8 +118,13 @@ cd -
|
|||||||
|
|
||||||
PATH=node_modules/.bin/:$PATH
|
PATH=node_modules/.bin/:$PATH
|
||||||
|
|
||||||
echo "Running tests"
|
if test x"$OPT_COVERAGE" = xyes; then
|
||||||
mocha -t 10000 -u tdd ${MOCHA_OPTS} ${TESTS}
|
echo "Running tests with coverage"
|
||||||
|
./node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -u tdd -t 5000 ${TESTS}
|
||||||
|
else
|
||||||
|
echo "Running tests"
|
||||||
|
mocha -u tdd -t 5000 ${TESTS}
|
||||||
|
fi
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user