jsdoc/test/runner.js
Jeff Williams 751bea1b0a fixes for Node.js compatibility (see details)
- new Rhino .jar to help find module paths
(https://github.com/hegemonic/rhino/commit/31b70105)
- make __dirname and process.cwd() provide the current module path; use
only env.dirname for JSDoc's home dir; fix callers
- get rid of jsdoc/util/include (and update test framework accordingly)
- avoid running Rhino/Node.js tests on the wrong runtime
- remove support for global 'publish' function, which relied upon
jsdoc/util/include
- update jsdoc/util/dumper for consistency with Node.js'
JSON.stringify()
- fix jsdoc/util/runtime to detect Node.js correctly
- add Node.js versions of jsdoc/fs and jsdoc/path
- other minor cleanup
2013-10-25 23:30:56 -07:00

61 lines
1.5 KiB
JavaScript

/*global env: true, jasmine: true */
/*
* 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 fs = require('jsdoc/fs');
var myGlobal = require('jsdoc/util/global');
var path = require('path');
fs.existsSync = fs.existsSync || path.existsSync;
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) {
require( path.join(env.dirname, 'test/jasmine-jsdoc') );
testsCompleteCallback = testsCompleteCallback || callback;
if (index < specFolders.length) {
jasmine.executeSpecsInFolder(specFolders[index], onComplete, opts);
}
else {
process.nextTick(function() {
testsCompleteCallback(failedCount);
});
}
};
onComplete = function(runner, log) {
if (runner.results().failedCount !== 0) {
failedCount += runner.results().failedCount;
}
index++;
runNextFolder();
};