2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2013-07-26 20:31:24 +02:00
|
|
|
|
2013-08-20 06:15:41 +02:00
|
|
|
cd "$(dirname "$0")"/..
|
2013-07-27 00:03:46 +02:00
|
|
|
|
2013-12-02 23:46:09 +01:00
|
|
|
export NODE_PATH=/usr/lib/nodejs:static
|
2016-08-04 18:29:30 +02:00
|
|
|
export PATH=$PATH:node_modules/.bin
|
2013-08-01 17:53:10 +02:00
|
|
|
|
2016-07-30 16:43:28 +02:00
|
|
|
INDEX_JS=frontend_tests/zjsunit/index.js
|
2013-07-30 23:54:33 +02:00
|
|
|
NODEJS=$(which nodejs || which node)
|
2016-08-08 22:50:23 +02:00
|
|
|
ret=0
|
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
if [ "$1" = "cover" ]; then
|
2013-08-20 06:20:02 +02:00
|
|
|
# Run a coverage test with Istanbul.
|
2016-08-11 18:33:52 +02:00
|
|
|
istanbul cover "$INDEX_JS" --dir var/node-coverage || ret=1;
|
2016-07-06 19:57:17 +02:00
|
|
|
|
|
|
|
elif [ "$1" = "-h" -o "$1" = "--help" ]; then
|
|
|
|
echo "Usage:
|
|
|
|
`basename $0` - to run all tests
|
|
|
|
`basename $0` util.js - to run tests from util.js
|
|
|
|
`basename $0` util.js activity.js - to run tests from util.js and activity.js
|
2016-08-03 22:07:42 +02:00
|
|
|
`basename $0` cover - to run tests and generate code coverage
|
2016-07-06 19:57:17 +02:00
|
|
|
"
|
|
|
|
exit 0
|
|
|
|
|
2013-08-20 06:20:02 +02:00
|
|
|
else
|
|
|
|
# Normal testing, no coverage analysis.
|
|
|
|
# Run the index.js test runner, which runs all the other tests.
|
2016-08-08 22:50:23 +02:00
|
|
|
"$NODEJS" --stack-trace-limit=100 "$INDEX_JS" $@ || ret=1;
|
2013-08-20 06:20:02 +02:00
|
|
|
fi
|
2016-08-08 22:50:23 +02:00
|
|
|
|
|
|
|
if [ $ret = '0' ]; then
|
|
|
|
echo "Test(s) passed. SUCCESS!"
|
|
|
|
else
|
|
|
|
echo "FAIL - Test(s) failed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit $ret
|