78 lines
5.3 KiB
JavaScript
78 lines
5.3 KiB
JavaScript
|
"use strict";
|
||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
|
if (k2 === undefined) k2 = k;
|
||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||
|
}) : (function(o, m, k, k2) {
|
||
|
if (k2 === undefined) k2 = k;
|
||
|
o[k2] = m[k];
|
||
|
}));
|
||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
|
}) : function(o, v) {
|
||
|
o["default"] = v;
|
||
|
});
|
||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||
|
if (mod && mod.__esModule) return mod;
|
||
|
var result = {};
|
||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||
|
__setModuleDefault(result, mod);
|
||
|
return result;
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.TapTest = void 0;
|
||
|
const plugins = __importStar(require("./tapbundle.plugins"));
|
||
|
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
|
||
|
const smarttime_1 = require("@pushrocks/smarttime");
|
||
|
class TapTest {
|
||
|
/**
|
||
|
* constructor
|
||
|
*/
|
||
|
constructor(optionsArg) {
|
||
|
this.testDeferred = plugins.smartpromise.defer();
|
||
|
this.testPromise = this.testDeferred.promise;
|
||
|
this.description = optionsArg.description;
|
||
|
this.hrtMeasurement = new smarttime_1.HrtMeasurement();
|
||
|
this.parallel = optionsArg.parallel;
|
||
|
this.status = 'pending';
|
||
|
this.tapTools = new tapbundle_classes_taptools_1.TapTools(this);
|
||
|
this.testFunction = optionsArg.testFunction;
|
||
|
}
|
||
|
/**
|
||
|
* run the test
|
||
|
*/
|
||
|
async run(testKeyArg) {
|
||
|
this.hrtMeasurement.start();
|
||
|
this.testKey = testKeyArg;
|
||
|
const testNumber = testKeyArg + 1;
|
||
|
try {
|
||
|
await this.testFunction(this.tapTools);
|
||
|
if (this.status === 'timeout') {
|
||
|
throw new Error('Test succeeded, but timed out...');
|
||
|
}
|
||
|
this.hrtMeasurement.stop();
|
||
|
console.log(`ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
||
|
this.status = 'success';
|
||
|
this.testDeferred.resolve(this);
|
||
|
}
|
||
|
catch (err) {
|
||
|
this.hrtMeasurement.stop();
|
||
|
console.log(`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
||
|
this.testDeferred.resolve(this);
|
||
|
// if the test has already succeeded before
|
||
|
if (this.status === 'success') {
|
||
|
this.status = 'errorAfterSuccess';
|
||
|
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull');
|
||
|
}
|
||
|
else {
|
||
|
this.status = 'error';
|
||
|
}
|
||
|
// if the test is allowed to fail
|
||
|
if (this.failureAllowed) {
|
||
|
console.log(`please note: failure allowed!`);
|
||
|
}
|
||
|
console.log(err);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
exports.TapTest = TapTest;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDZEQUErQztBQUUvQyw2RUFBd0Q7QUFJeEQsb0RBQXNEO0FBT3RELE1BQWEsT0FBTztJQVdsQjs7T0FFRztJQUNILFlBQVksVUFBbUY7UUFMeEYsaUJBQVksR0FBc0IsT0FBTyxDQUFDLFlBQVksQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQ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