Skip to content

Commit a26633f

Browse files
committed
chore: fix integration tests
1 parent f9cce4d commit a26633f

File tree

7 files changed

+41
-16
lines changed

7 files changed

+41
-16
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ before_install:
33
- npm install -g grunt-cli
44
script:
55
- grunt --stack travis
6-
- integration-testing/run-integration-tests.sh
76
email:
87
on_failure: change
98
on_success: never

Gruntfile.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function(grunt) {
1717
]
1818
},
1919

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

2222
copy: {
2323
dist: {
@@ -192,7 +192,13 @@ module.exports = function(grunt) {
192192
cmd: 'npm run checkTypes',
193193
bg: false,
194194
fail: true
195+
},
196+
integrationTests: {
197+
cmd: './integration-testing/run-integration-tests.sh',
198+
bg: false,
199+
fail: true
195200
}
201+
196202
},
197203

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

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

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

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

7-
var output = Handlebars.compile('Author: {{author}}')({author: 'Yehuda'});
8-
if (output !== 'Author: Yehuda') {
9-
throw new Error('Compiled output (' + compiledOutput + ') did not match expected output (' + expectedOutput + ')');
10-
}
11-
12-
assert.equal(output, 'Author: Yehuda')
7+
var template = Handlebars.compile('Author: {{author}}');
8+
var output = template({author: 'Yehuda'});
9+
assert.strictEqual(output, 'Author: Yehuda');
1310

1411
console.log('Success');

integration-testing/multi-nodejs-test/test.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

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

67
# This script tests with precompiler and the built distribution with multiple NodeJS version.
@@ -14,10 +15,12 @@ cd "$( dirname "$( readlink -f "$0" )" )" || exit 1
1415
# A list of NodeJS versions is expected as cli-args
1516
echo "Handlebars should be able to run in various versions of NodeJS"
1617
for i in 0.10 0.12 4 5 6 7 8 9 10 11 ; do
17-
rm target -rf
18+
rm target node_modules package-lock.json -rf
1819
mkdir target
1920
nvm install "$i"
20-
nvm exec "$i" node ./run-handlebars.js >/dev/null || exit 1
21-
nvm exec "$i" node ../../bin/handlebars precompile-test-template.txt.hbs -f target/precompile-test-template.js || exit 1
21+
nvm exec "$i" npm install
22+
nvm exec "$i" npm run test || exit 1
23+
nvm exec "$i" npm run test-precompile || exit 1
24+
2225
echo Success
2326
done
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
npm install
24
npm test
35

0 commit comments

Comments
 (0)