forked from MadPacMan/PCFW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntFile.js
73 lines (65 loc) · 2.41 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
module.exports = function(grunt) {
"use strict";
var readOptionalJSON = function(filepath) {
var data = {};
try {
data = grunt.file.readJSON(filepath);
} catch(e) {}
return data;
};
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
dst: readOptionalJSON("dist/.destination.json"),
testswarm: {
tests: (function() {
var path = require('path'),
files = require('fs').readdirSync('./test/unit/'),
testFiles = [];
files.forEach(function(file) {
var basename = path.basename(file),
extname = path.extname(file);
//Only .js files
if (extname === '.js')
testFiles.push(basename.substr(0,basename.length - extname.length))
});
return testFiles;
})()
},
});
grunt.registerTask("testswarm", function(commit,configFile) {
var jobName,
testswarm = require("testswarm"),
testUrls = [],
pull = /PR-(\d+)/.exec(commit),
config = grunt.file.readJSON(configFile),
tests = grunt.config([this.name,"tests"]),
testNames = tests;
if ( pull )
jobName = "PCFW pull <a href='https://github.com/TATDK/PCFW/pull/" + pull[ 1 ] + "'>#" + pull[ 1 ] + "</a>";
else
jobName = "PCFW commit #<a href='https://github.com/TATDK/PCFW/commit/" + commit + "'>" + commit.substr( 0, 10 ) + "</a>";
tests.forEach(function(test) {
testUrls.push(config.testUrl + commit + "/test/index.html?module=" + test);
});
tests.forEach(function(test) {
testNames.push(test+" min");
testUrls.push(config.testUrl + commit + "/test/index.min.html?module=" + test);
});
testswarm({
url: config.swarmUrl,
pollInterval: 10000,
timeout: 1000 * 60 * 30,
done: this.async()
}, {
authUsername: config.authUsername,
authToken: config.authToken,
jobName: jobName,
runMax: config.runMax,
"runNames[]": testNames,
"runUrls[]": testUrls,
"browserSets[]": "PCFW"
});
});
// Default grunt
grunt.registerTask("default",[]);
};