forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.js
66 lines (53 loc) · 1.58 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
55
56
57
58
59
60
61
62
63
64
65
66
/*global jasmine */
/*
* Test 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 env = require('jsdoc/env');
var fs = require('jsdoc/fs');
var logger = require('jsdoc/util/logger');
var path = require('path');
fs.existsSync = fs.existsSync || path.existsSync;
require( path.join(env.dirname, 'test/jasmine-jsdoc') );
var hasOwnProp = Object.prototype.hasOwnProperty;
var opts = {
verbose: env.opts.verbose || false,
showColors: env.opts.nocolor === true ? false : true
};
var extensions = 'js';
var match = env.opts.match || '.';
if (match instanceof Array) {
match = match.join("|");
}
opts.matcher = new RegExp("(" + match + ")\\.(" + extensions + ")$", 'i');
var specFolders = [
path.join(env.dirname, 'test/specs'),
path.join(env.dirname, 'plugins/test/specs')
];
var failedCount = 0;
var index = 0;
var testsCompleteCallback;
var onComplete;
var runNextFolder = module.exports = function(callback) {
testsCompleteCallback = testsCompleteCallback || callback;
// silence the logger while we run the tests
logger.setLevel(logger.LEVELS.SILENT);
if (index < specFolders.length) {
jasmine.executeSpecsInFolder(specFolders[index], onComplete, opts);
}
else {
process.nextTick(function() {
testsCompleteCallback(null, failedCount);
});
}
};
onComplete = function(runner, log) {
if (runner.results().failedCount !== 0) {
failedCount += runner.results().failedCount;
}
index++;
runNextFolder();
};