Skip to content

Commit

Permalink
Simplified testing by adding tags to gulp, eg. gulp test --quick
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Malakoff authored and Kevin Malakoff committed Jul 27, 2014
1 parent e196ccd commit 3134eb9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $ gulp build
Please run tests before submitting a pull request:

```
$ gulp test-quick
$ gulp test --quick
```

and eventually all tests:
Expand Down
15 changes: 6 additions & 9 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@ gulp.task 'build', buildLibraries = ->
gulp.task 'watch', ['build'], (callback) ->
return gulp.watch './src/**/*.coffee', -> buildLibraries()

testFn = (options={}) -> (callback) ->
gutil.log "Running Node.js tests #{if options.quick then '(quick)' else ''}"
gulp.task 'test', ['build'], (callback) ->
tags = ("@#{tag.replace(/^[-]+/, '')}" for tag in process.argv.slice(3)).join(' ')
gutil.log "Running Node.js tests #{tags}"

global.__test__parameters = require './test/parameters' # ensure that globals for the target backend are loaded
global.__test__app_framework = {factory: (require 'backbone-rest/test/parameters_express4'), name: 'express4'}
mocha_options = if options.quick then {grep: '@no_options'} else {}
gulp.src("{node_modules/backbone-#{if options.quick then 'orm' else '{orm,rest}'}/,}test/{issues,spec/sync}/**/*.tests.coffee")
.pipe(mocha(_.extend({reporter: 'dot'}, mocha_options)))
gulp.src("{node_modules/backbone-#{if tags.indexOf('@quick') >= 0 then 'orm' else '{orm,rest}'}/,}test/{issues,spec/sync}/**/*.tests.coffee")
.pipe(mocha({reporter: 'dot', grep: tags}))
.pipe es.writeArray (err) ->
delete global.__test__parameters # cleanup globals
callback(err)
process.exit(0|(!!err))
return # promises workaround: https://github.com/gulpjs/gulp/issues/455

gulp.task 'test', ['build'], testFn()
gulp.task 'test-quick', ['build'], testFn({quick: true})
gulp.task 'test-quick', [], testFn({quick: true})

# gulp.task 'benchmark', ['build'], (callback) ->
# (require './test/lib/run_benchmarks')(callback)
# return # promises workaround: https://github.com/gulpjs/gulp/issues/455
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--compilers coffee:coffee-script/register
--require test/parameters
--timeout 10000
--grep @no_options
--grep @quick

0 comments on commit 3134eb9

Please sign in to comment.