diff --git a/.gitignore b/.gitignore index 15072ab908..87ae27219e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ lib-cov pids logs results +build node_modules npm-debug.log diff --git a/README.md b/README.md index 3cee2612be..c63a552ae5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ bootstrap-ui ============ -Directives specific to twitter bootstrap \ No newline at end of file +Directives specific to twitter bootstrap + +## Development +### Prepare your environment +* Install [Node.js](http://nodejs.org/) and NPM (should come with) +* Install global dev dependencies: `npm install -g grunt@0.3.x testacular@0.2.x` + +### Run unit tests +* Start testacular server: `grunt server` +* Run test: `grunt test-run` + +### Before commit +* Build the whole project: `grunt` - this will run `lint`, `test`, and `concat` targets \ No newline at end of file diff --git a/grunt.js b/grunt.js index 43d1a317ff..dc6f7e9ebd 100644 --- a/grunt.js +++ b/grunt.js @@ -1,6 +1,3 @@ - -var testacular = require('testacular'); - module.exports = function(grunt) { // Project configuration. @@ -10,7 +7,7 @@ module.exports = function(grunt) { }, watch: { files: '', - tasks: 'lint test-run concat' + tasks: 'lint test-run' }, concat: { build: { @@ -32,47 +29,45 @@ module.exports = function(grunt) { } }); - // Default task. - grunt.registerTask('default', 'lint test concat'); + //register before and after test tasks so we've don't have to change cli options on the goole's CI server + grunt.registerTask('before-test', 'lint'); + grunt.registerTask('after-test', 'concat'); - grunt.registerTask('server', 'start testacular server', function() { - var done = this.async(); - testacular.server.start({configFile: 'test/test-config.js'}); - }); + // Default task. + grunt.registerTask('default', 'before-test test after-test'); - function spawnTestacular(args, callback) { - grunt.utils.spawn({ - cmd: __dirname + "/node_modules/.bin/" + - (process.platform === 'win32' ? 'testacular.cmd' : 'testacular'), + // Testacular configuration + var runTestacular = function(command, options) { + var testacularCmd = process.platform === 'win32' ? 'testacular.cmd' : 'testacular'; + var args = [command, 'test/test-config.js'].concat(options); + var done = grunt.task.current.async(); + var child = grunt.utils.spawn({ + cmd: testacularCmd, args: args - }, callback); - } - - grunt.registerTask('test-run', 'run tests against continuous testacular server', function() { - var done = this.async(); - spawnTestacular(['run'], function(error, result, code) { - if (error) { - grunt.warn("Make sure the testacular server is online: run `grunt server`.\n" + - "Also make sure you have a browser open to http://localhost:9018/.\n" + - grunt.warn(error.stdout + error.stderr)); - setTimeout(done,1000); + }, function(err, result, code) { + if (code) { + done(false); } else { - grunt.log.write(result.stdout); done(); } }); - }); + child.stdout.pipe(process.stdout); + child.stderr.pipe(process.stderr); + }; grunt.registerTask('test', 'run tests on single-run server', function() { - var done = this.async(); - spawnTestacular(['start', 'test/test-config.js','--single-run', '--log-level=warn'], function(error, result, code) { - if (error) { - grunt.warn(error.stdout + error.stderr); - } else { - grunt.log.write(result.stdout); - } - done(); - }); + //Can augment options with command line arguments + var options = ['--single-run', '--no-auto-watch'].concat(this.args); + runTestacular('start', options); + }); + + grunt.registerTask('server', 'start testacular server', function() { + var options = ['--no-single-run', '--no-auto-watch'].concat(this.args); + runTestacular('start', options); }); + grunt.registerTask('test-run', 'run tests against continuous testacular server', function() { + var options = ['--single-run', '--no-auto-watch'].concat(this.args); + runTestacular('run', options); + }); }; diff --git a/package.json b/package.json index 491599717f..f84c3ad968 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "name": "angular-ui-bootstrap", "version": "0.1.0", "dependencies": { - "testacular": "~0.2.1" + }, + "devDependencies": { + "testacular": "~0.2.0" } } diff --git a/test/test-config.js b/test/test-config.js index 4806dd8d3c..01c2310e72 100644 --- a/test/test-config.js +++ b/test/test-config.js @@ -10,7 +10,7 @@ files = [ 'test/lib/angular-1.0.2.js', 'test/lib/angular-1.0.2-mocks.js', 'common/*.js', - 'directives/**/*.js', + 'directives/**/*.js' ]; // list of files to exclude