Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor testing frameworks #658

Merged
merged 7 commits into from
May 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"eqeqeq" : true,
"forin" : false,
"immed" : true,
"latedef" : true,
"latedef" : "nofunc",
"newcap" : true,
"noarg" : true,
"noempty" : true,
Expand Down Expand Up @@ -58,7 +58,14 @@
"passfail" : false,
"white" : false,

"predef" : [
"define"
]
"globals" : {
"define" : false,
"describe" : false,
"expect" : false,
"it" : false,
"beforeEach" : false,
"afterEach" : false,
"beforeAll" : false,
"afterAll" : false
}
}
8 changes: 0 additions & 8 deletions .npmignore

This file was deleted.

138 changes: 53 additions & 85 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,38 @@
/*global module:false,__dirname:true*/
module.exports = function(grunt) {
//--------------------------------------------------
//------------Project config------------------------
//--------------------------------------------------
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
pkg: pkg,
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Released under the <%= pkg.license %> License */\n',
// Task configuration.
shell: {
oldTests: {
command: 'node test/server.js',
peg: {
parser: {
src: 'src/dust.pegjs',
dest: 'lib/parser.js',
options: {
stdout: true,
failOnError: true
}
},
testRhino : {
command : function() {
var commandList = [],
fs = require('fs'),
rhinoFolder = 'test/rhino/';
fs.readdirSync(__dirname + '/' + rhinoFolder + 'lib').forEach( function(rhinoJar) {
if(rhinoJar.indexOf('.jar') >= 0) {
commandList.push('java -jar ' + rhinoFolder + 'lib/' + rhinoJar + ' -f ' + rhinoFolder + 'rhinoTest.js');
}
});
return commandList.join(' && ');
},
options : {
stdout: true,
failOnError: true
}
},
// these are old that should eventually be rewritten to take advantage of grunt and the current build process
buildParser: {
command: 'node src/build.js',
options: {
stdout: true
wrapper: function(src, parser) {
var buildMsg = 'Do not edit this file directly. It is automatically generated from src/dust.pegjs';
var wrapper = grunt.file.read("src/umdParserWrapper.js").replace('@@build', buildMsg).split('@@parser');
return wrapper[0] + parser + wrapper[1];
}
}
},
bench: {
command: 'node benchmark/server.js',
}
},
execute: {
testRhino: {
src: 'node_modules/.bin/rhino*',
options: {
stdout: true
args: ['-f', 'test/rhino.spec.js']
}
},
doc: {
command: 'node docs/build.js',
options: {
stdout: true
}
buildParser: {
src: 'src/build.js'
}
},
concat: {
Expand Down Expand Up @@ -120,7 +99,7 @@ module.exports = function(grunt) {
src: 'Gruntfile.js'
},
libs: {
src: ['lib/**/*.js', 'src/**/*.js', '!lib/parser.js'] // don't hint the parser which is autogenerated from pegjs
src: ['lib/**/*.js', '!lib/parser.js'] // don't hint the parser which is autogenerated from pegjs
}
},
connect: {
Expand All @@ -132,26 +111,19 @@ module.exports = function(grunt) {
}
},
jasmine: {
options: {
keepRunner: false,
display: 'short',
specs: ['test/templates/all.js', 'test/helpers/template.helper.js', 'test/templates.spec.js'],
vendor: ['node_modules/ayepromise/ayepromise.js', 'test/lib/highland.js']
},
/*tests production (minified) code*/
testProd: {
src: 'tmp/dust-full.min.js',
options: {
keepRunner: false,
display: 'short',
helpers: ['test/jasmine-test/spec/coreTests.js'],
specs: ['test/jasmine-test/spec/testHelpers.js', 'test/jasmine-test/spec/renderTestSpec.js'],
vendor: ['node_modules/ayepromise/ayepromise.js', 'test/lib/highland.js']
}
src: 'tmp/dust-full.min.js'
},
/*tests unminified code, mostly used for debugging by `grunt dev` task*/
testDev : {
src: 'tmp/dust-full.js',
options: {
keepRunner: false,
helpers: '<%=jasmine.testProd.options.helpers%>',
specs : '<%=jasmine.testProd.options.specs%>',
vendor: '<%=jasmine.testProd.options.vendor%>'
}
src: 'tmp/dust-full.js'
},
/*runs unit tests with jasmine and collects test coverage info via istanbul template
* tests unminified version of dust to make sure test coverage starts are correctly calculated
Expand All @@ -161,11 +133,7 @@ module.exports = function(grunt) {
coverage : {
src: 'tmp/dust-full.js',
options: {
keepRunner: false,
display: 'none',
helpers: '<%=jasmine.testProd.options.helpers%>',
specs : '<%=jasmine.testProd.options.specs%>',
vendor: '<%=jasmine.testProd.options.vendor%>',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'tmp/coverage/coverage.json',
Expand All @@ -181,27 +149,27 @@ module.exports = function(grunt) {
}
},
jasmine_nodejs: {
cjs: {
specs: ['test/jasmine-test/spec/cjsSpec.js'],
options: {
reporters: {
console: {
colors: false,
verbose: false
}
options: {
useHelpers: true,
reporters: {
console: {
colors: false,
verbosity: 0
}
}
},
core: {
specs: ['test/core.spec.js']
},
cjs: {
specs: ['test/commonJS.spec.js']
},
dustc: {
specs: ['test/jasmine-test/spec/cli/*'],
options: {
reporters: {
console: {
colors: false,
verbose: false
}
}
}
helpers: ['test/cli/matchers.helper.js'],
specs: ['test/cli/*']
},
templates: {
specs: ['test/templates.spec.js']
}
},
watch: {
Expand All @@ -214,7 +182,7 @@ module.exports = function(grunt) {
tasks: ['jshint:gruntfile']
},
lib_test: {
files: ['<%= jshint.libs.src %>', '<%= jasmine.testProd.options.specs %>'],
files: ['<%= jshint.libs.src %>', '<%= jasmine.options.specs %>'],
tasks: ['testPhantom']
}
},
Expand Down Expand Up @@ -285,24 +253,24 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-execute');
grunt.loadNpmTasks('grunt-peg');
grunt.loadNpmTasks('grunt-jasmine-nodejs');
grunt.loadNpmTasks('grunt-github-changes');

//--------------------------------------------------
//------------Grunt task aliases -------------------
//--------------------------------------------------
grunt.registerTask('buildLib', ['jshint:libs', 'concat']);
grunt.registerTask('build', ['clean:build', 'shell:buildParser', 'buildLib', 'uglify']);
grunt.registerTask('build', ['clean:build', 'peg', 'buildLib', 'uglify']);

//test tasks
grunt.registerTask('testNode', ['jasmine_nodejs:cjs', 'shell:oldTests']);
grunt.registerTask('testRhino', ['build', 'shell:testRhino']);
grunt.registerTask('testNode', ['jasmine_nodejs:templates', 'jasmine_nodejs:core', 'jasmine_nodejs:cjs']);
grunt.registerTask('testRhino', ['build', 'execute:testRhino']);
grunt.registerTask('testPhantom', ['build', 'jasmine:testProd']);
grunt.registerTask('testCli', ['jasmine_nodejs:dustc']);
grunt.registerTask('test', ['build', 'jasmine:testProd', 'testCli', 'testNode', 'shell:testRhino', 'jasmine:coverage']);
grunt.registerTask('test', ['build', 'jasmine:testProd', 'testCli', 'testNode', 'execute:testRhino', 'jasmine:coverage']);

//decide whether to run all tests or just the Node tests for Travis CI
grunt.registerTask('travis', (process.env.TEST === 'all') ? ['test'] : ['testNode', 'testCli']);
Expand All @@ -317,7 +285,7 @@ module.exports = function(grunt) {
grunt.registerTask('coverage', ['build', 'jasmine:coverage', 'log:coverage']);

//release tasks
grunt.registerTask('copyForRelease', ['clean:dist', 'copy:core', 'copy:coreMin', 'copy:full', 'copy:fullMin', 'copy:license', 'log:copyForRelease']);
grunt.registerTask('copyForRelease', ['clean:dist', 'copy', 'log:copyForRelease']);
grunt.registerTask('buildRelease', ['test', 'githubChanges', 'copyForRelease']);
grunt.registerTask('releasePatch', ['bump-only:patch', 'buildRelease', 'bump-commit', 'log:release']);
grunt.registerTask('releaseMinor', ['bump-only:minor', 'buildRelease', 'bump-commit', 'log:release']);
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Asynchronous Javascript templating for the browser and server. This fork is main

### NPM

**Important**: We recommend that you lock your version of Dust to a specific minor version, instead of a major version. By default, NPM will add `"dustjs-linkedin": "^2.x.y"` to your package.json, which will install new minor versions automatically.

npm install --save --production dustjs-linkedin
# If you want the dustc compiler available globally
npm install -g dustjs-linkedin
npm install --global --production dustjs-linkedin

If you want to add the [Dust helpers](https://github.com/linkedin/dustjs-helpers) or [secure filters](https://github.com/linkedin/dustjs-filters-secure):

Expand Down
1 change: 0 additions & 1 deletion lib/compiler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/*jshint latedef:false */
(function(root, factory) {
if (typeof define === "function" && define.amd && define.amd.dust === true) {
define("dust.compile", ["dust.core", "dust.parse"], function(dust, parse) {
Expand Down
1 change: 0 additions & 1 deletion lib/dust.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(function (root, factory) {
/*global define*/
if (typeof define === 'function' && define.amd && define.amd.dust === true) {
define('dust.core', [], factory);
} else if (typeof exports === 'object') {
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Do not edit the parser directly. This is a generated file created using a build script and the PEG grammar. */
/* Do not edit this file directly. It is automatically generated from src/dust.pegjs */
(function(root, factory) {
if (typeof define === "function" && define.amd && define.amd.dust === true) {
define("dust.parse", ["dust.core"], function(dust) {
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@
"grunt-contrib-jshint": "~0.11.1",
"grunt-contrib-uglify": "~0.8.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-gh-pages": "~0.10.0",
"grunt-execute": "~0.2.2",
"grunt-github-changes": "~0.0.6",
"grunt-jasmine-nodejs": "~1.0.2",
"grunt-jasmine-nodejs": "~1.4.0",
"grunt-peg": "~1.5.0",
"grunt-shell": "~1.1.2",
"grunt-template-jasmine-istanbul": "~0.3.3",
"highland": "2.4.0",
"jasmine": "~2.2.1",
"pegjs": "0.8.0",
"rhino-1_7r3-bin": "~1.0.1",
"rhino-1_7r5-bin": "~1.0.1",
"tmp": "0.0.25"
},
"license": "MIT",
Expand Down
20 changes: 0 additions & 20 deletions src/build.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/umdParserWrapper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BUILD_MESSAGE_HERE */
/* @@build */
(function(root, factory) {
if (typeof define === "function" && define.amd && define.amd.dust === true) {
define("dust.parse", ["dust.core"], function(dust) {
Expand All @@ -13,7 +13,7 @@
factory(root.dust);
}
}(this, function(dust) {
var parser = 'PARSER_CODE_HERE';
var parser = @@parser;

// expose parser methods
dust.parse = parser.parse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/*global describe,expect,it,afterEach */
/*jshint unused:false*/
var path = require('path'),
fs = require('fs'),
exec = require('child_process').exec;

var ROOT_DIR = path.resolve(__dirname, '../../../../'),
var ROOT_DIR = path.resolve(__dirname, '../../'),
BIN_DIR = path.join(ROOT_DIR, 'bin'),
TMP_DIR = require('tmp').dirSync().name,
FIXTURE_DIR = path.join(__dirname, 'fixtures');

var packageJson = require(path.join(ROOT_DIR, 'package.json'));

require('./lib/matchers.js');

describe('dustc', function() {

describe('template piped from stdin', function() {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fs = require('fs'),
dust = require('../../../../../lib/dust');
dust = require('../../');

var matchers = {};

Expand Down
Loading