Skip to content

Commit

Permalink
chore: fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nknapp committed Aug 31, 2019
1 parent f9cce4d commit a26633f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ before_install:
- npm install -g grunt-cli
script:
- grunt --stack travis
- integration-testing/run-integration-tests.sh
email:
on_failure: change
on_success: never
Expand Down
11 changes: 9 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(grunt) {
]
},

clean: ['tmp', 'dist', 'lib/handlebars/compiler/parser.js'],
clean: ['tmp', 'dist', 'lib/handlebars/compiler/parser.js', 'integration-testing/**/node_modules'],

copy: {
dist: {
Expand Down Expand Up @@ -192,7 +192,13 @@ module.exports = function(grunt) {
cmd: 'npm run checkTypes',
bg: false,
fail: true
},
integrationTests: {
cmd: './integration-testing/run-integration-tests.sh',
bg: false,
fail: true
}

},

watch: {
Expand Down Expand Up @@ -241,8 +247,9 @@ module.exports = function(grunt) {
grunt.registerTask('bench', ['metrics']);
grunt.registerTask('sauce', process.env.SAUCE_USERNAME ? ['tests', 'connect', 'saucelabs-mocha'] : []);

grunt.registerTask('travis', process.env.PUBLISH ? ['default', 'sauce', 'metrics', 'publish:latest'] : ['default']);
grunt.registerTask('travis', process.env.PUBLISH ? ['default', 'bgShell:integrationTests', 'sauce', 'metrics', 'publish:latest'] : ['default']);

grunt.registerTask('dev', ['clean', 'connect', 'watch']);
grunt.registerTask('default', ['clean', 'build', 'test', 'release']);
grunt.registerTask('integration-tests', ['default', 'bgShell:integrationTests']);
};
3 changes: 2 additions & 1 deletion integration-testing/multi-nodejs-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
target
package-lock.json
16 changes: 16 additions & 0 deletions integration-testing/multi-nodejs-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "multi-nodejs-test",
"version": "1.0.0",
"description": "Simple integration test with all relevant NodeJS-versions.",
"keywords": [],
"author": "Nils Knappmeier",
"private": true,
"license": "MIT",
"dependencies": {
"handlebars": "file:../.."
},
"scripts": {
"test": "node run-handlebars.js",
"test-precompile": "handlebars precompile-test-template.txt.hbs"
}
}
15 changes: 6 additions & 9 deletions integration-testing/multi-nodejs-test/run-handlebars.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// This test should run successfully with node 0.10 as long as Handlebars has been compiled before
// This test should run successfully with node 0.10++ as long as Handlebars has been compiled before
var assert = require('assert');
var Handlebars = require('../../');
var Handlebars = require('handlebars');

console.log('Testing build Handlebars with Node version ' + process.version);
console.log('Testing built Handlebars with Node version ' + process.version);

var output = Handlebars.compile('Author: {{author}}')({author: 'Yehuda'});
if (output !== 'Author: Yehuda') {
throw new Error('Compiled output (' + compiledOutput + ') did not match expected output (' + expectedOutput + ')');
}

assert.equal(output, 'Author: Yehuda')
var template = Handlebars.compile('Author: {{author}}');
var output = template({author: 'Yehuda'});
assert.strictEqual(output, 'Author: Yehuda');

console.log('Success');
9 changes: 6 additions & 3 deletions integration-testing/multi-nodejs-test/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

cd "$( dirname "$( readlink -f "$0" )" )" || exit 1
# shellcheck disable=SC1090
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# This script tests with precompiler and the built distribution with multiple NodeJS version.
Expand All @@ -14,10 +15,12 @@ cd "$( dirname "$( readlink -f "$0" )" )" || exit 1
# A list of NodeJS versions is expected as cli-args
echo "Handlebars should be able to run in various versions of NodeJS"
for i in 0.10 0.12 4 5 6 7 8 9 10 11 ; do
rm target -rf
rm target node_modules package-lock.json -rf
mkdir target
nvm install "$i"
nvm exec "$i" node ./run-handlebars.js >/dev/null || exit 1
nvm exec "$i" node ../../bin/handlebars precompile-test-template.txt.hbs -f target/precompile-test-template.js || exit 1
nvm exec "$i" npm install
nvm exec "$i" npm run test || exit 1
nvm exec "$i" npm run test-precompile || exit 1

echo Success
done
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

npm install
npm test

0 comments on commit a26633f

Please sign in to comment.