forked from nathanboktae/mocha-phantomjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
40 lines (32 loc) · 1.16 KB
/
Cakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
fs = require 'fs'
path = require 'path'
async = require 'async'
{print} = require 'util'
{spawn} = require 'child_process'
testCodes = []
task 'build', 'Build project', ->
build()
task 'test', 'Run tests', ->
build -> test()
build = (callback) ->
builder = (args...) ->
(callback) ->
coffee = spawn 'coffee', args
coffee.stderr.on 'data', (data) -> process.stderr.write data.toString()
coffee.stdout.on 'data', (data) -> print data.toString()
coffee.on 'exit', (code) -> callback?(code,code)
async.parallel [
builder('-c', '-o', 'test/lib', 'test/src')
], (err, results) -> callback?() unless err
test = ->
tester = (file) ->
(callback) ->
mocha = spawn 'mocha', ['-u', 'bdd', '-R', 'spec', '-t', '20000', '--colors', "test/lib/#{file}"]
mocha.stdout.pipe process.stdout, end: false
mocha.stderr.pipe process.stderr, end: false
mocha.on 'exit', (code) -> callback?(code,code)
testFiles = ['mocha-phantomjs.js']
testers = (tester file for file in testFiles)
async.series testers, (err, results) ->
passed = results.every (code) -> code is 0
process.exit if passed then 0 else 1