Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x 2x 1x 2x 4x 4x 4x 4x 4x 2x 3x 2x 3x 2x 9x 9x 1x 1x 8x 1x 1x 7x 1x 1x 6x 1x 5x 1x 4x 1x 3x 2x | "use strict";
/**
* Runs tests.
*
* - executes `runner.js` file, which is entry point to load and execute
* files with tests
* - connects custom reporter to `mochajs`.
*
* @function
* @name run
* @arg {function} cb - Callback.
*/
var fs = require("fs");
var path = require("path");
var fse = require("fs-extra");
var Mocha = require("mocha");
const cluster = require("./cluster");
var CONF = require("./config");
var hacking = require("./hacking");
var tools = require("./tools");
const utils = require("./utils");
var run = cb => {
resetReport();
if (CONF.session.uncaughtException !== "mocha") hacking.suppressMochaUncaught();
var mocha = new Mocha({ grep: CONF.filter.grep,
timeout: CONF.chunk.timeout,
retries: CONF.chunk.retries,
reporter: path.resolve(__dirname, "reporter") });
mocha.addFile(path.resolve(__dirname, "loader.js"));
if (cb) {
_run(mocha, cb);
} else {
return new Promise(resolve => _run(mocha, resolve));
}
};
/**
* Runs mocha.
*
* @ignore
*/
var _run = (mocha, fin) => {
mocha.run(code => {
var clampedCode = Math.min(code, 255);
if (CONF.session.isPassed) clampedCode = 0;
if (!CONF.session.isPassed && clampedCode === 0) clampedCode = 1;
fin(clampedCode);
});
};
/**
* Resets report folder.
*
* @ignore
*/
var resetReport = () => {
if (CONF.report.clear && fs.existsSync(CONF.report.dir)) {
fse.removeSync(CONF.report.dir);
}
fse.mkdirsSync(CONF.report.dir);
};
/**
* Runs glace framework.
*
* @arg {function} cb - Callback.
*/
var glaceRun = cb => {
utils.setLog();
if (CONF.tools.stepsList) {
tools.printSteps(CONF.tools.stepsFilter);
return cb();
} else if (CONF.tools.fixturesList) {
tools.printFixtures(CONF.tools.fixturesFilter);
return cb();
} else if (CONF.tools.testsList) {
tools.printTests(CONF.tools.testsFilter);
return cb();
} else if (CONF.tools.checkTestrail) {
return tools.checkTestrail(cb);
} else if (CONF.tools.pluginsList) {
return tools.printPlugins(cb);
} else if (CONF.cluster.isMaster) {
return cluster.launch(cb);
} else {
return run(cb);
}
};
module.exports = glaceRun;
|