forked from mootools/mootools-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
148 lines (119 loc) · 3.1 KB
/
Gruntfile.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
"use strict";
var MAX_PARALLEL = 3;
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
'connect': {
testserver: {
options: {
// We use end2end task (which does not start the webserver)
// and start the webserver as a separate process
// to avoid https://github.com/joyent/libuv/issues/826
port: 8000,
hostname: '0.0.0.0',
middleware: function(connect, options) {
return [
function(req, resp, next) {
// cache get requests to speed up tests on travis
if (req.method === 'GET') {
resp.setHeader('Cache-control', 'public, max-age=3600');
}
next();
},
connect.static(options.base)
];
}
}
}
},
'packager': {
options: {
name: 'Core'
},
all: {
src: 'Source/**/*.js',
dest: 'mootools-all.js'
},
nocompat: {
options: {
strip: ['.*compat'],
only: '<%= grunt.option("file") && "Core/" + grunt.option("file") %>'
},
src: 'Source/**/*.js',
dest: 'mootools-nocompat.js'
},
specs: {
options: {
name: 'Specs'
},
src: 'Specs/<%= grunt.option("module") || "**" %>/<%= grunt.option("file") || "*" %>.js',
dest: 'mootools-specs.js'
},
'specs-nocompat': {
options: {
name: 'Specs',
strip: ['.*compat'],
only: '<%= grunt.option("file") && "Specs/" + grunt.option("file") %>'
},
src: 'Specs/**/*.js',
dest: 'mootools-specs.js'
}
},
'karma': {
options: {
captureTimeout: 60000 * 2,
singleRun: true,
frameworks: ['jasmine', 'sinon'],
files: ['Tests/Utilities/*.js', 'mootools-*.js'],
sauceLabs: {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
testName: 'MooTools-Core'
}
},
continuous: {
browsers: ['PhantomJS']
},
dev: {
singleRun: false,
browsers: ['PhantomJS'],
reporters: 'dots'
}
},
'clean': {
all: {
src: 'mootools-*.js'
}
}
});
grunt.registerTask('default', ['clean', 'packager:all', 'packager:specs', 'karma:continuous']);
grunt.registerTask('nocompat', ['clean', 'packager:nocompat', 'packager:specs-nocompat', 'karma:continuous']);
grunt.registerTask('sauce', 'Launch specs against SauceLabs™ VMs', function(){
grunt.task.run(['clean', 'packager:all', 'packager:specs']);
var browsers = {
chrome_linux: { browserName: 'chrome', platform: 'linux' },
firefox_linux: { browserName: 'firefox', platform: 'linux' },
opera_win2000: { browserName: 'opera', platform: 'Windows 2008', version: '12'}
};
var set = [];
for (var i in browsers){
browsers[i].base = 'SauceLabs';
set.push([i, browsers[i]]);
}
var nset = [];
while (set.length) nset.push(set.splice(0, MAX_PARALLEL))
grunt.task.run(nset.map(function(set, i){
var browsers = {};
set.forEach(function(bits){
browsers[bits[0]] = bits[1];
});
grunt.config.set('karma.sauce' + i, {
port: 9876,
customLaunchers: browsers,
browsers: Object.keys(browsers),
reporters: 'saucelabs'
});
return 'karma:sauce' + i;
}));
});
};