69 lines
5.4 KiB
JavaScript
69 lines
5.4 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const plugins = require("./tapbundle.plugins");
|
|
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
|
|
// imported interfaces
|
|
const early_1 = require("early");
|
|
class TapTest {
|
|
/**
|
|
* constructor
|
|
*/
|
|
constructor(optionsArg) {
|
|
this.testDeferred = plugins.smartq.defer();
|
|
this.testPromise = this.testDeferred.promise;
|
|
this.description = optionsArg.description;
|
|
this.hrtMeasurement = new early_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
|
|
*/
|
|
run(testKeyArg) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
this.hrtMeasurement.start();
|
|
this.testKey = testKeyArg;
|
|
let testNumber = testKeyArg + 1;
|
|
try {
|
|
yield 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4QztBQUU5Qyw2RUFBdUQ7QUFFdkQsc0JBQXNCO0FBQ3RCLGlDQUFzQztBQVd0QztJQVdFOztPQUVHO0lBQ0gsWUFBYSxVQUlaO1FBVEQsaUJBQVksR0FBc0IsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUN4RCxnQkFBVyxHQUFxQixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQTtRQVN2RCxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUE7UUFDekMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLHNCQUFjLEVBQUUsQ0FBQTtRQUMxQyxJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUE7UUFDbkMsSUFBSSxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUE7UUFDdkIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLHFDQUFRLENBQUMs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