Skip to content

Commit

Permalink
Merge branch '4.x' into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewLeedham committed Sep 1, 2019
2 parents ef2984e + f119497 commit 2d8bd99
Show file tree
Hide file tree
Showing 35 changed files with 498 additions and 392 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,3 +12,4 @@ npm-debug.log
sauce_connect.log*
.idea
yarn-error.log
/handlebars-release.tgz
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,6 @@ before_install:
- npm install -g grunt-cli
script:
- grunt --stack travis
- multi-nodejs-test/run-tests.sh 0.10 0.12 4 5 6 7 8 9 10 11
email:
on_failure: change
on_success: never
Expand Down
13 changes: 10 additions & 3 deletions Gruntfile.js
Expand Up @@ -13,11 +13,11 @@ module.exports = function(grunt) {
'tasks/**/*.js',
'lib/**/!(*.min|parser).js',
'spec/**/!(*.amd|json2|require).js',
'multi-nodejs-test/*.js'
'integration-testing/**/*.js'
]
},

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']);
};
2 changes: 1 addition & 1 deletion components/bower.json
@@ -1,6 +1,6 @@
{
"name": "handlebars",
"version": "4.1.2",
"version": "4.1.2-0",
"main": "handlebars.js",
"license": "MIT",
"dependencies": {}
Expand Down
2 changes: 1 addition & 1 deletion components/handlebars.js.nuspec
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>handlebars.js</id>
<version>4.1.2</version>
<version>4.1.2-0</version>
<authors>handlebars.js Authors</authors>
<licenseUrl>https://github.com/wycats/handlebars.js/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/wycats/handlebars.js/</projectUrl>
Expand Down
2 changes: 1 addition & 1 deletion components/package.json
@@ -1,6 +1,6 @@
{
"name": "handlebars",
"version": "4.1.2",
"version": "4.1.2-0",
"license": "MIT",
"jspm": {
"main": "handlebars",
Expand Down
12 changes: 12 additions & 0 deletions integration-testing/README.md
@@ -0,0 +1,12 @@
Add a new integration test by creating a new subfolder

Add a file "test.sh" to that runs the test. "test.sh" should exit with a non-zero exit code
and display an error message, if something goes wrong.

* An integration test should reflect real-world setups that use handlebars.
* It should compile a minimal template and compare the output to an expected output.
* It should use "../.." as dependency for Handlebars so that the currently built library is used.

Currently, integration tests are only running on Linux, especially in travis-ci.


12 changes: 12 additions & 0 deletions integration-testing/multi-nodejs-test/.eslintrc.js
@@ -0,0 +1,12 @@
module.exports = {
"extends": "eslint:recommended",
"globals": {
"self": false
},
"env": {
"node": true
},
"rules": {
'no-console': 'off'
}
}
2 changes: 2 additions & 0 deletions integration-testing/multi-nodejs-test/.gitignore
@@ -0,0 +1,2 @@
target
package-lock.json
16 changes: 16 additions & 0 deletions integration-testing/multi-nodejs-test/package.json
@@ -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"
}
}
@@ -0,0 +1 @@
Author: {{author}}
11 changes: 11 additions & 0 deletions integration-testing/multi-nodejs-test/run-handlebars.js
@@ -0,0 +1,11 @@
// This test should run successfully with node 0.10++ as long as Handlebars has been compiled before
var assert = require('assert');
var Handlebars = require('handlebars');

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

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

console.log('Success');
@@ -1,6 +1,7 @@
#!/bin/bash

cd "$( dirname "$( readlink -f "$0" )" )"
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 @@ -13,9 +14,13 @@ cd "$( dirname "$( readlink -f "$0" )" )"

# 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 "$@" ; do
for i in 0.10 0.12 4 5 6 7 8 9 10 11 ; do
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 template.txt.hbs >/dev/null || 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
13 changes: 13 additions & 0 deletions integration-testing/run-integration-tests.sh
@@ -0,0 +1,13 @@
#!/bin/bash

cd "$( dirname "$( readlink -f "$0" )" )" || exit 1

for i in */test.sh ; do
(
echo "----------------------------------------"
echo "-- Running integration test: $i"
echo "----------------------------------------"
cd "$( dirname "$i" )" || exit 1
./test.sh || exit 1
)
done
3 changes: 3 additions & 0 deletions integration-testing/webpack-test/.gitignore
@@ -0,0 +1,3 @@
node_modules
dist
package-lock.json
21 changes: 21 additions & 0 deletions integration-testing/webpack-test/package.json
@@ -0,0 +1,21 @@
{
"name": "webpack-test",
"description": "Various tests with Handlebars and Webpack",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "webpack --config webpack.config.js",
"test": "node dist/main.js"
},
"private": true,
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"handlebars": "file:../..",
"handlebars-loader": "^1.7.1",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.7"
}
}
@@ -0,0 +1,6 @@
import Handlebars from 'handlebars/dist/handlebars';

import {assertEquals} from './lib/assert';

const template = Handlebars.compile('Author: {{author}}');
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
@@ -0,0 +1,6 @@
import Handlebars from 'handlebars';
import {assertEquals} from './lib/assert';


const template = Handlebars.compile('Author: {{author}}');
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
@@ -0,0 +1,8 @@
import {assertEquals} from './lib/assert';

import testTemplate from './test-template.handlebars';
assertEquals(testTemplate({author: 'Yehuda'}).trim(), 'Author: Yehuda');


const testTemplateRequire = require('./test-template.handlebars');
assertEquals(testTemplateRequire({author: 'Yehuda'}).trim(), 'Author: Yehuda');
@@ -0,0 +1,6 @@
import * as Handlebars from 'handlebars/dist/handlebars';

import {assertEquals} from './lib/assert';

const template = Handlebars.compile('Author: {{author}}');
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
@@ -0,0 +1,5 @@
import * as Handlebars from 'handlebars';
import {assertEquals} from './lib/assert';

const template = Handlebars.compile('Author: {{author}}');
assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda');
5 changes: 5 additions & 0 deletions integration-testing/webpack-test/src/lib/assert.js
@@ -0,0 +1,5 @@
export function assertEquals(actual, expected) {
if (actual !== expected) {
throw new Error(`Expected "${actual}" to equal "${expected}"`);
}
}
2 changes: 2 additions & 0 deletions integration-testing/webpack-test/src/test-template.handlebars
@@ -0,0 +1,2 @@
Author: {{author}}

16 changes: 16 additions & 0 deletions integration-testing/webpack-test/test.sh
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

# Cleanup: package-lock and "npm ci" is not working with local dependencies
rm dist package-lock.json -rf
npm install
npm run build

for i in dist/*-test.js ; do
echo "----------------------"
echo "-- Running $i"
echo "----------------------"
node "$i"
echo "Success"
done
22 changes: 22 additions & 0 deletions integration-testing/webpack-test/webpack.config.js
@@ -0,0 +1,22 @@
const fs = require('fs');

const testFiles = fs.readdirSync('src');
const entryPoints = {};
testFiles
.filter(file => file.match(/-test.js$/))
.forEach(file => {
entryPoints[file] = `./src/${file}`;
});

module.exports = {
entry: entryPoints,
output: {
filename: '[name]',
path: __dirname + '/dist'
},
module: {
rules: [
{test: /\.handlebars$/, loader: 'handlebars-loader'}
]
}
};
2 changes: 1 addition & 1 deletion lib/handlebars/base.js
Expand Up @@ -4,7 +4,7 @@ import {registerDefaultHelpers} from './helpers';
import {registerDefaultDecorators} from './decorators';
import logger from './logger';

export const VERSION = '4.1.2';
export const VERSION = '4.1.2-0';
export const COMPILER_REVISION = 7;

export const REVISION_CHANGES = {
Expand Down

0 comments on commit 2d8bd99

Please sign in to comment.