Revised Grunt translations task to use build:test

* Added build:test task to generate translation JS for tests.

* Removed test/spec/translations.js from the repository, added to .gitignore.

* Updated test/run_tests.sh to run build:test, and accept an optional argument
  to run a particular test suite.
This commit is contained in:
Kevin Gisi 2015-03-22 22:39:48 -04:00
parent 1e59336d09
commit 7bed1efb21
4 changed files with 41 additions and 27 deletions

2
.gitignore vendored
View file

@ -23,3 +23,5 @@ test/*.map
website/public/docs
*.sublime-workspace
coverage.html
test/spec/translations.js

View file

@ -230,7 +230,8 @@ module.exports = function(grunt) {
// Register tasks.
grunt.registerTask('compile:sprites', ['clean:sprite', 'sprite', 'cssmin']);
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
grunt.registerTask('build:dev', ['browserify', 'stylus', 'test:prepare:translations']);
grunt.registerTask('build:dev', ['browserify', 'stylus']);
grunt.registerTask('build:test', ['test:prepare:translations', 'build:dev']);
grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]);

View file

@ -5,42 +5,55 @@ TEST_DB_URI="mongodb://localhost/$TEST_DB"
TEST_SERVER_PORT=3001
# Build assets
grunt build:dev
grunt build:test
# Launch Node server and Selenium
echo "= Recreating test database"
mongo "$TEST_DB" --eval "db.dropDatabase()"
if [ -z "$TRAVIS" ]; then
./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager start > /dev/null &
trap "curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer" EXIT
if [ -z "$1" ] || [ "$1" == "protractor" ]; then
./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager start > /dev/null &
trap "curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer" EXIT
# Wait for selenium
MAX_WAIT=30
WAITED=0
until nc -z localhost 4444; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Waited $MAX_WAIT seconds, but Selenium never responded" >&2
kill $NODE_PID
exit 1
fi
sleep 1
let 'WAITED+=1'
done
# Wait for selenium
MAX_WAIT=30
WAITED=0
until nc -z localhost 4444; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Waited $MAX_WAIT seconds, but Selenium never responded" >&2
kill $NODE_PID
exit 1
fi
sleep 1
let 'WAITED+=1'
done
fi
fi
NODE_DB_URI="$TEST_DB_URI" PORT=$TEST_SERVER_PORT node ./website/src/server.js > /dev/null &
NODE_PID=$!
trap "kill $NODE_PID" EXIT
echo "= Running mocha specs"
NODE_ENV=testing mocha || exit $?
if [ -z "$TRAVIS" ]; then
echo "= Running protractor specs"
NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $?
if [ -z "$1" ] || [ "$1" == "mocha" ]; then
echo "= Running mocha specs"
NODE_ENV=testing mocha || exit $?
fi
echo "= Running karma specs"
NODE_ENV=testing grunt karma:continuous
# If we're only running protractor, we need to let the server spin up.
if [ "$1" == "protractor" ]; then
sleep 2
fi
if [ -z "$TRAVIS" ]; then
if [ -z "$1" ] || [ "$1" == "protractor" ]; then
echo "= Running protractor specs"
NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $?
fi
fi
if [ -z "$1" ] || [ "$1" == "karma" ]; then
echo "= Running karma specs"
NODE_ENV=testing grunt karma:continuous || exit $?
fi

File diff suppressed because one or more lines are too long