-
Notifications
You must be signed in to change notification settings - Fork 2
/
grunt.js
92 lines (76 loc) · 2.63 KB
/
grunt.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var fs = require("fs");
var childProcess = require("child_process");
var util = require("util");
process.env.PATH = process.env.PATH + ":" + __dirname + "/node_modules/.bin";
module.exports = function(grunt) {
this.jsSources = ['grunt.js', 'src/*.js', 'src/test/*.js', 'src/ntest/*.js'];
// Project configuration.
grunt.initConfig({
meta: {
title: 'Multi (Test1)',
name: "Frohwalt Egerer",
homepage: 'http://et42.de'
},
watch: {
files: this.jsSources,
tasks: 'default'
},
lint: {
all: this.jsSources
}
});
// Default task to be run during development
grunt.registerTask('default', 'lint browserTest zombie');
// Tasks that are too slow for interactive use
grunt.registerTask('molasses', 'selenium');
// Tasks run on npm install (travics-ci)
grunt.registerTask('npminstall', 'default molasses');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-growl');
grunt.registerTask('browserTest', "run browser tests", function runTests() {
var done = this.async();
var started = false;
server = runCmd("buster-server", []);
phantom = runCmd("phantomjs", ["phantomjs-buster.js"]);
phantom.stdout.on('data', function(data) {
if (data.toString().indexOf("success") != -1 && !started) {
started = true;
buster = runCmd("buster-test", ["-rdots", "-gamd"]);
buster.on('exit', function(code) {
server.kill('SIGINT');
phantom.kill('SIGINT');
done();
});
}
});
});
grunt.registerTask('zombie', "run zombie tests", function runTests() {
var done = this.async();
buster = runCmd("buster-test", ["-rdots", "-gnode"]);
buster.on('exit', function(code) {
grunt.log.writeln("Zombie returned "+code);
done(code === 0);
});
});
grunt.registerTask('selenium', "run selenium tests", function runTests() {
var done = this.async();
sel = runCmd("./selenium/test.sh");
sel.on('exit', function(code) {
grunt.log.writeln("Selenium returned "+code);
done(code === 0);
});
});
};
function runCmd(cmd, argv) {
var run = childProcess.spawn(cmd, argv, {
env: process.env,
setsid: true
});
run.stdout.on('data', function(data) {
process.stdout.write(data);
});
run.stderr.on('data', function(data) {
process.stderr.write(data);
});
return run;
}