stryker
Version:
The extendable JavaScript mutation testing framework
50 lines • 2.25 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var test_runner_1 = require("stryker-api/test_runner");
var TestRunnerDecorator_1 = require("./TestRunnerDecorator");
var log4js_1 = require("log4js");
var objectUtils_1 = require("../utils/objectUtils");
/**
* Wraps a test runner and implements the timeout functionality.
*/
var TimeoutDecorator = /** @class */ (function (_super) {
tslib_1.__extends(TimeoutDecorator, _super);
function TimeoutDecorator() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.log = log4js_1.getLogger(TimeoutDecorator.name);
return _this;
}
TimeoutDecorator.prototype.run = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var result;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.log.debug('Starting timeout timer (%s ms) for a test run', options.timeout);
return [4 /*yield*/, objectUtils_1.timeout(_super.prototype.run.call(this, options), options.timeout)];
case 1:
result = _a.sent();
if (result === objectUtils_1.TimeoutExpired) {
return [2 /*return*/, this.handleTimeout()];
}
else {
return [2 /*return*/, result];
}
return [2 /*return*/];
}
});
});
};
TimeoutDecorator.prototype.handleTimeout = function () {
var _this = this;
this.log.debug('Timeout expired, restarting the process and reporting timeout');
return this.dispose()
.then(function () { return _this.createInnerRunner(); })
.then(function () { return _this.init(); })
.then(function () { return ({ status: test_runner_1.RunStatus.Timeout, tests: [] }); });
};
return TimeoutDecorator;
}(TestRunnerDecorator_1.default));
exports.default = TimeoutDecorator;
//# sourceMappingURL=TimeoutDecorator.js.map
;