tia
Version:
Time is All (logs driven test engine with ExtJs support)
63 lines • 2.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// options for all high level API functions.
function defaultOptions() {
return {
logHl: true,
logLl: false,
passHl: true,
passLl: false,
passLlPrinting: true,
};
}
/**
* Wraps some generator for high level actions.
* @param gen
* @param msg
* @param options
*/
function* wrapGenerator(gen, msg, options) {
const opts = gT.commonMiscUtils.mergeOptions(options, defaultOptions);
if (opts.logHl) {
gT.l.println(`BEGIN: "${msg}"`);
}
// In case of fail, the state will be restored before next test.
const oldLogLl = gT.lL.setDefaultLlLogAction(opts.logLl);
const oldPassLl = gT.lL.setLlPassCounting(opts.passLl);
const oldPassLlPrinting = gT.lL.setLlPassPrinting(opts.passLlPrinting);
const res = yield* gen();
gT.lL.setDefaultLlLogAction(oldLogLl);
gT.lL.setLlPassCounting(oldPassLl);
gT.lL.setLlPassPrinting(oldPassLlPrinting);
if (opts.logHl) {
gT.l.println(`END: "${msg}"`);
}
if (opts.passHl) {
gIn.tInfo.addPassForce();
}
return res;
}
exports.wrapGenerator = wrapGenerator;
async function wrapAsync(func, msg, options) {
const opts = gT.commonMiscUtils.mergeOptions(options, defaultOptions);
if (opts.logHl) {
gT.l.println(`BEGIN: "${msg}"`);
}
// In case of fail, the state will be restored before next test.
const oldLogLl = gT.lL.setDefaultLlLogAction(opts.logLl);
const oldPassLl = gT.lL.setLlPassCounting(opts.passLl);
const oldPassLlPrinting = gT.lL.setLlPassPrinting(opts.passLlPrinting);
const res = await func();
gT.lL.setDefaultLlLogAction(oldLogLl);
gT.lL.setLlPassCounting(oldPassLl);
gT.lL.setLlPassPrinting(oldPassLlPrinting);
if (opts.logHl) {
gT.l.println(`END: "${msg}"`);
}
if (opts.passHl) {
gIn.tInfo.addPassForce();
}
return res;
}
exports.wrapAsync = wrapAsync;
//# sourceMappingURL=high-level.js.map