64 lines
5.1 KiB
JavaScript
64 lines
5.1 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();
|
|
try {
|
|
yield this.testFunction(this.tapTools);
|
|
if (this.status === 'timeout') {
|
|
throw new Error('Test succeeded, but timed out...');
|
|
}
|
|
this.hrtMeasurement.stop();
|
|
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
|
this.status = 'success';
|
|
this.testDeferred.resolve(this);
|
|
}
|
|
catch (err) {
|
|
this.hrtMeasurement.stop();
|
|
console.log(`not ok ${testKeyArg + 1} - ${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');
|
|
}
|
|
// 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4QztBQUU5Qyw2RUFBdUQ7QUFFdkQsc0JBQXNCO0FBQ3RCLGlDQUFzQztBQVd0QztJQVVFOztPQUVHO0lBQ0gsWUFBYSxVQUlaO1FBVEQsaUJBQVksR0FBc0IsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUN4RCxnQkFBVyxHQUFxQixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQTtRQVN2RCxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUE7UUFDekMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLHNCQUFjLEVBQUUsQ0FBQTtRQUMxQyxJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUE7UUFDbkMsSUFBSSxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUE7UUFDdkIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLHFDQUFRLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDbEMsSUFBSSxDQUFDLFlBQVksR0FBRyxVQ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