UNPKG

stryker

Version:
54 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var report_1 = require("stryker-api/report"); var Timer_1 = require("../utils/Timer"); var ProgressKeeper = /** @class */ (function () { function ProgressKeeper() { this.progress = { survived: 0, tested: 0, total: 0, }; } ProgressKeeper.prototype.onAllMutantsMatchedWithTests = function (matchedMutants) { this.timer = new Timer_1.default(); this.mutantIdsWithoutCoverage = matchedMutants.filter(function (m) { return m.scopedTestIds.length === 0; }).map(function (m) { return m.id; }); this.progress.total = matchedMutants.length - this.mutantIdsWithoutCoverage.length; }; ProgressKeeper.prototype.onMutantTested = function (result) { if (!this.mutantIdsWithoutCoverage.some(function (id) { return result.id === id; })) { this.progress.tested++; } if (result.status === report_1.MutantStatus.Survived) { this.progress.survived++; } }; ProgressKeeper.prototype.getEtc = function () { var totalSecondsLeft = Math.floor(this.timer.elapsedSeconds() / this.progress.tested * (this.progress.total - this.progress.tested)); if (isFinite(totalSecondsLeft) && totalSecondsLeft > 0) { var hours = Math.floor(totalSecondsLeft / 3600); var minutes = Math.floor(totalSecondsLeft / 60 % 60); var seconds = Math.floor(totalSecondsLeft % 60); return this.formatEtc(hours, minutes, seconds); } else { return 'n/a'; } }; ProgressKeeper.prototype.formatEtc = function (hours, minutes, seconds) { var output; if (hours > 0) { output = hours + "h, " + minutes + "m, " + seconds + "s"; } else if (minutes > 0) { output = minutes + "m, " + seconds + "s"; } else { output = seconds + "s"; } return output; }; return ProgressKeeper; }()); exports.default = ProgressKeeper; //# sourceMappingURL=ProgressKeeper.js.map