forked from cozy/cozy-home-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
71 lines (61 loc) · 2.18 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
fs = require 'fs'
# Grab test files
walk = (dir, fileList) ->
list = fs.readdirSync(dir)
if list
for file in list
if file
filename = dir + '/' + file
stat = fs.statSync(filename)
if stat and stat.isDirectory()
walk(filename, fileList)
else if filename.substr(-6) == "coffee"
fileList.push(filename)
fileList
{exec} = require 'child_process'
testFiles = walk("test", [])
uiTestFiles = walk("client/test", [])
task 'tests', 'run tests through mocha', ->
runTests testFiles
task 'tests:client', 'run tests through mocha', ->
runTests uiTestFiles
runTests = (fileList) ->
console.log "Run tests with Mocha for " + fileList.join(" ")
command = "mocha " + fileList.join(" ") + " --reporter spec "
command += "--compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
console.log stdout
if err
console.log "Running mocha caught exception: \n" + err
process.exit 1
else
process.exit 0
option '-f', '--file [FILE]', 'test file to run'
task 'tests:file', 'run test through mocha for a given file', (options) ->
file = options.file
console.log "Run tests with Mocha for " + file
command = "mocha " + file + " --reporter spec "
command += "--compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
if err
console.log "Running mocha caught exception: \n" + err
console.log stdout
task "xunit", "Run tests and save result in a file called xunit.xml", ->
process.env.TZ = "Europe/Paris"
command = "mocha "
command += " --compilers coffee:coffee-script -R xunit > xunit.xml"
exec command, (err, stdout, stderr) ->
console.log stdout
task "xunit:client", "", ->
process.env.TZ = "Europe/Paris"
command = "mocha client/test/*"
command += " --compilers coffee:coffee-script -R xunit > xunitclient.xml"
exec command, (err, stdout, stderr) ->
console.log stdout
task "lint", "Run coffeelint on backend files", ->
process.env.TZ = "Europe/Paris"
command = "coffeelint "
command += " -f coffeelint.json -r app/ lib/ config/ test/"
exec command, (err, stdout, stderr) ->
console.log err
console.log stdout