All files config.js

83.33% Statements 35/42
70.97% Branches 22/31
50% Functions 2/4
86.84% Lines 33/38

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                                              21x   21x 21x   21x 21x   21x   21x 21x     21x 21x     21x 21x     21x       21x       21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x   21x     21x     21x       21x     11x     21x  
"use strict";
 
/**
 * `GlaceJS` tests generator config.
 *
 * @namespace GlaceConfig
 * @prop {object} gen - Generator options.
 * @prop {string} gen.stepsFile - File path to load steps description. May be
 *  `json` or `yaml` format.
 * @prop {string} gen.outFile - File path to save generator output (`yaml` format).
 *  If file path doesn't have `yaml` extension it will be added.
 * @prop {number} gen.stepsUsage - Number of step usage in test case. Overrides
 *  the same value for individual steps.
 * @prop {string} gen.filter - Chunk of step name in order to choose tests
 *  which contain this step.
 * @prop {boolean} [gen.namesOnly=false] - Flag to print only step names without
 *  full info.
 * @prop {number} [gen.stepsUniq=0] - Amount of uniq sequences of steps in
 *  order to filter tests.
 * @prop {number} [gen.testsLimit=1000000] - Maximum amount of tests.
 * @prop {number} [gen.stepsLimit] - Maximum amount of steps per test.
 */
 
var path = require("path");
 
var _ = require("lodash");
var U = require("glace-utils");
 
var config = U.config;
var args = config.args;
 
config.gen = U.defVal(config.gen, {});
 
Eif (args._.length) {
    config.gen.stepsFiles = _.clone(args._);
}
 
Eif (args.genStepsFiles) {
    config.gen.stepsFiles = args.genStepsFiles.split(/ +/g).filter(o => o);
}
 
Eif (config.gen.stepsFiles) {
    config.gen.stepsFiles = config.gen.stepsFiles.map(f => path.resolve(U.cwd, f));
}
 
Iif (args.genTestsFiles) {
    config.gen.testsFiles = args.genTestsFiles.split(/ +/g).filter(o => o);
};
 
Iif (config.gen.testsFiles) {
    config.gen.testsFiles = config.gen.testsFiles.map(f => path.resolve(U.cwd, f));
};
 
config.gen.use = !!args.genStepsFiles || !!args.genTestsFiles;
config.gen.outFile = args.genOutputFile;
config.gen.filter = args.genStepsFilter;
config.gen.stepsUsage = args.genStepsUsage;
config.gen.namesOnly = !!args.genNamesOnly;
config.gen.stepsUniq = +(args.genStepsUniq || 0);
config.gen.testsReverse = !!args.genTestsReverse;
config.gen.testsMax = +args.genTestsMax;
config.gen.testsLimit = +(args.genTestsLimit || 1000000);
config.gen.stepsLimit = +(args.genStepsLimit || Infinity);
config.gen.testsOnly = !!args.genTestsOnly;
config.gen.testsShuffle = !!args.genTestsShuffle;
config.gen.trainResult = path.resolve(
    U.cwd, (args.genTrainResult || "train-result.json"));
Iif (args.genTrain) {
    config.gen.train = path.resolve(U.cwd, args.genTrain);
}
Iif (args.genLoadTrain) {
    config.gen.pretrain = path.resolve(U.cwd, args.genLoadTrain);
}
Iif (args.genTrainBefore) {
    config.gen.trainBefore = path.resolve(U.cwd, args.genTrainBefore);
}
 
if (config.gen.outFile &&
        !config.gen.outFile.endsWith(".yaml") &&
        !config.gen.outFile.endsWith(".yml")) {
    config.gen.outFile += ".yml";
};
 
module.exports = config;