forked from h5bp/ant-build-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.js
54 lines (47 loc) · 1.3 KB
/
runner.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
/*
* Tests Steps:
* 1. Get Jasmine
* 2. Get the test options
* 3. Get the list of directories to run tests from
* 4. Run Jasmine on each directory
*/
var jasmine = require('test/jasmine-jsdoc');
var extensions = "js";
var match = ".";
var verbose = env.opts.verbose || false;
var coffee = env.opts.coffee || false;
var matches = env.opts.match || false;
if (coffee) {
extensions = "js|coffee";
}
if (matches) {
if (matches instanceof Array) {
match = matches.join("|");
} else {
match = matches;
}
}
var helperCollection = require('test/spec-collection');
var specFolders = ['test/specs', 'plugins/test/specs'];
var failedCount = 0;
var index = 0;
for (var key in jasmine) {
this[key] = jasmine[key];
}
var onComplete = function(runner, log) {
if (runner.results().failedCount != 0) {
failedCount++;
}
index++;
runNextFolder();
};
var specFolder = null;
var runNextFolder = function() {
if (index < specFolders.length) {
jasmine.loadHelpersInFolder(specFolders[index], new RegExp("helpers\\.(" + extensions + ")$", 'i'));
var regExpSpec = new RegExp("(" + match + ")\\.(" + extensions + ")$", 'i');
jasmine.executeSpecsInFolder(specFolders[index], onComplete, verbose, regExpSpec);
}
};
runNextFolder();
process.exit(failedCount);