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 106 107 108 109 110 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 3x 3x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 2x 1x 1x 1x 1x 1x | "use strict";
/**
* `GlaceJS` tests generator.
*
* @module
*/
require("./help");
var fs = require("fs");
var U = require("glace-utils");
var CONF = require("./config");
var generate = require("./generator").generate;
var train = require("./train");
var stream;
Iif (CONF.gen.outFile) {
stream = fs.createWriteStream(CONF.gen.outFile, { flags: "w" });
};
/**
* Runs tests generator.
*
* @function
*/
exports.run = () => {
Iif (CONF.gen.train) {
var model = train(CONF.gen.train);
fs.writeFileSync(CONF.gen.trainResult, JSON.stringify(model, null, " "));
return;
}
var [tests, unusedSteps] = generate({ filter: CONF.gen.filter });
printTests(tests);
printUnusedSteps(unusedSteps);
};
/**
* @ignore
* @function
* @arg {Step[]} steps
*/
var printUnusedSteps = steps => {
if (!steps.length) return;
console.log("Unused steps detected!".red.bold);
for (var s of steps) console.log(` - ${s.name}`.red);
console.log();
console.log("Check steps income and outcome definitions".yellow);
process.exit(1);
};
/**
* @ignore
* @function
* @arg {Test[]} tests
*/
var printTests = tests => {
var count = 0;
for (var t of tests) {
write(`Test case ${++count}:`, "yellow");
for (var s of t.steps) {
var name = ` - ${s.name}`;
if (CONF.gen.namesOnly) {
write(name, "green");
continue;
};
Eif (s.actions.length) name += ":";
write(name, "green");
for (var act of s.actions) {
write(` - ${act}`, "blue");
};
Eif (s.expected.length) {
write(" - expected:", "red");
for (var e of s.expected) {
write(` - ${e}`, "magenta");
};
};
};
write("");
};
};
/**
* @ignore
* @function
* @arg {string} string
* @arg {string} color
*/
var write = (string, color) => {
if (CONF.gen.outFile) {
stream.write(string + "\n");
} else {
Iif (color) string = string[color];
console.log(string);
};
};
process.on("uncaughtException", U.exit("Uncaught Exception"));
process.on("unhandledRejection", U.exit("Unhandled Rejection"));
|