2017-04-28 07:49:57 +00:00
|
|
|
"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 });
|
2017-05-04 21:15:08 +00:00
|
|
|
const plugins = require("./tapbundle.plugins");
|
2017-04-28 07:49:57 +00:00
|
|
|
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
|
|
|
|
// imported interfaces
|
|
|
|
const early_1 = require("early");
|
|
|
|
class TapTest {
|
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*/
|
|
|
|
constructor(optionsArg) {
|
2017-05-04 21:15:08 +00:00
|
|
|
this.testDeferred = plugins.smartq.defer();
|
|
|
|
this.testPromise = this.testDeferred.promise;
|
2017-04-28 07:49:57 +00:00
|
|
|
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();
|
2017-07-11 13:10:05 +00:00
|
|
|
this.testKey = testKeyArg;
|
|
|
|
let testNumber = testKeyArg + 1;
|
2017-04-28 07:49:57 +00:00
|
|
|
try {
|
|
|
|
yield this.testFunction(this.tapTools);
|
|
|
|
if (this.status === 'timeout') {
|
|
|
|
throw new Error('Test succeeded, but timed out...');
|
|
|
|
}
|
|
|
|
this.hrtMeasurement.stop();
|
2017-07-11 13:10:05 +00:00
|
|
|
console.log(`ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
2017-04-28 07:49:57 +00:00
|
|
|
this.status = 'success';
|
2017-05-04 21:15:08 +00:00
|
|
|
this.testDeferred.resolve(this);
|
2017-04-28 07:49:57 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.hrtMeasurement.stop();
|
2017-07-11 13:10:05 +00:00
|
|
|
console.log(`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
2017-05-26 23:46:38 +00:00
|
|
|
this.testDeferred.resolve(this);
|
2017-05-04 21:15:08 +00:00
|
|
|
// if the test has already succeeded before
|
2017-04-28 07:49:57 +00:00
|
|
|
if (this.status === 'success') {
|
|
|
|
this.status = 'errorAfterSuccess';
|
|
|
|
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull');
|
|
|
|
}
|
2017-07-11 13:10:05 +00:00
|
|
|
else {
|
|
|
|
this.status = 'error';
|
|
|
|
}
|
2017-05-04 21:15:08 +00:00
|
|
|
// if the test is allowed to fail
|
2017-04-28 07:49:57 +00:00
|
|
|
if (this.failureAllowed) {
|
|
|
|
console.log(`please note: failure allowed!`);
|
|
|
|
}
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.TapTest = TapTest;
|
2017-07-11 13:10:05 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc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