Skip to content

Commit

Permalink
went on a code-writing rampage, forgot to commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pthrasher committed Apr 26, 2013
1 parent ad82615 commit ff05920
Show file tree
Hide file tree
Showing 4 changed files with 581 additions and 189 deletions.
45 changes: 29 additions & 16 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ fs = require 'fs'
{print} = require 'sys'
child_process = require 'child_process'
watchit = require 'watchit'
_ = require 'underscore'

build = (watch, callback) ->
if typeof watch is 'function'
Expand All @@ -15,6 +16,20 @@ build = (watch, callback) ->
coffee.stderr.on 'data', (data) -> print data.toString()
coffee.on 'exit', (status) -> callback?() if status is 0

runTests = ->
suite?.kill()
suiteNames = [
'integration'
]
suiteIndex = 0
do runNextTestSuite = ->
return unless suiteName = suiteNames[suiteIndex]
suite = spawn "coffee", ["-e", "{reporters} = require 'nodeunit'; reporters.default.run ['#{suiteName}.coffee']"], cwd: 'test'
suite.stdout.on 'data', (data) -> print data.toString()
suite.stderr.on 'data', (data) -> print data.toString()
suite.on 'exit', -> suiteIndex++; runNextTestSuite()
invoke 'docs' # lest I forget

spawn = ->
arguments[0] += '.cmd' if process.platform is 'win32'
child_process.spawn.apply(child_process, arguments)
Expand All @@ -33,26 +48,24 @@ task 'build', 'Compile CoffeeScript source files', ->
task 'watch', 'Recompile CoffeeScript source files when modified', ->
build true

task 'test', 'Run the test suite (and re-run if anything changes)', ->
task 'test', 'Run the test suite once.', ->
build runTests

task 'testwatch', 'Run the test suite (and re-run if anything changes)', ->
suite = null
build ->
do runTests = ->
suite?.kill()
suiteNames = [
'integration'
]
suiteIndex = 0
do runNextTestSuite = ->
return unless suiteName = suiteNames[suiteIndex]
suite = spawn "coffee", ["-e", "{reporters} = require 'nodeunit'; reporters.default.run ['#{suiteName}.coffee']"], cwd: 'test'
suite.stdout.on 'data', (data) -> print data.toString()
suite.stderr.on 'data', (data) -> print data.toString()
suite.on 'exit', -> suiteIndex++; runNextTestSuite()
invoke 'docs' # lest I forget
runTests()

watchTargets = (targets..., callback) ->
for target in targets
watchit target, include: true, (event) ->
callback() unless event is 'success'
watchTargets 'src', -> build runTests
watchTargets 'test', 'Cakefile', runTests

watchTargets 'src', do ->
_.debounce ->
build runTests
, 25

watchTargets 'test', 'Cakefile', do ->
_.debounce runTests, 25

Loading

0 comments on commit ff05920

Please sign in to comment.