2020-07-13 08:03:56 -04:00
|
|
|
/* istanbul ignore file */
|
|
|
|
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2021-03-07 18:24:04 -05:00
|
|
|
exports.ReporterKeepAlive = void 0;
|
2020-07-13 08:03:56 -04:00
|
|
|
// Maximum time in seconds to suppress output
|
2020-08-23 19:39:57 -04:00
|
|
|
var MAX_DELAY = 60;
|
2020-07-13 08:03:56 -04:00
|
|
|
function getTime() {
|
|
|
|
return (new Date()).getTime();
|
|
|
|
}
|
2020-08-23 19:39:57 -04:00
|
|
|
var stdoutWrite = process.stdout.write.bind(process.stdout);
|
|
|
|
var logOut = "";
|
|
|
|
var capturing = false;
|
|
|
|
function log(message) {
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
|
|
|
if (capturing) {
|
|
|
|
logOut += message;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function captureLog(initialLog) {
|
|
|
|
capturing = true;
|
|
|
|
if (initialLog == null) {
|
|
|
|
initialLog = "";
|
|
|
|
}
|
|
|
|
logOut = initialLog;
|
2020-07-13 08:03:56 -04:00
|
|
|
process.stdout.write = function () {
|
|
|
|
var args = [];
|
|
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
|
|
args[_i] = arguments[_i];
|
|
|
|
}
|
2020-08-23 19:39:57 -04:00
|
|
|
logOut += "*";
|
|
|
|
return true;
|
2020-07-13 08:03:56 -04:00
|
|
|
};
|
2020-08-23 19:39:57 -04:00
|
|
|
}
|
|
|
|
function releaseLog() {
|
|
|
|
capturing = false;
|
|
|
|
var result = logOut;
|
|
|
|
process.stdout.write = stdoutWrite;
|
|
|
|
logOut = "";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
function ReporterKeepAlive(runner) {
|
|
|
|
var suites = 0;
|
|
|
|
var fails = 0;
|
|
|
|
var errors = [];
|
|
|
|
// Catch anything attempting to write to the consolea
|
|
|
|
captureLog();
|
2020-07-13 08:03:56 -04:00
|
|
|
// Force Output; Keeps the console output alive with periodic updates
|
|
|
|
var lastOutput = getTime();
|
|
|
|
function forceOutput() {
|
|
|
|
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
|
2020-08-23 19:39:57 -04:00
|
|
|
var currentLog = releaseLog();
|
|
|
|
console.log("# Keep Alive: " + currentLog);
|
|
|
|
captureLog();
|
|
|
|
lastOutput = getTime();
|
2020-07-13 08:03:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
var timer = setInterval(forceOutput, 1000);
|
|
|
|
runner.on('suite', function (suite) {
|
|
|
|
suites++;
|
|
|
|
fails = 0;
|
|
|
|
log("[");
|
|
|
|
});
|
|
|
|
runner.on('suite end', function () {
|
|
|
|
suites--;
|
|
|
|
log("]");
|
|
|
|
if (suites === 0) {
|
2020-08-23 19:39:57 -04:00
|
|
|
// Reset standard output
|
|
|
|
var currentLog = releaseLog();
|
|
|
|
if (logOut.length) {
|
|
|
|
console.log("# Keep Alive: " + currentLog);
|
|
|
|
}
|
|
|
|
// Stop the keep-alive poller
|
2020-07-13 08:03:56 -04:00
|
|
|
clearTimeout(timer);
|
2020-08-23 19:39:57 -04:00
|
|
|
// Dump out any errors encountered
|
|
|
|
console.log("#");
|
2020-07-13 08:03:56 -04:00
|
|
|
if (errors.length) {
|
2020-08-23 19:39:57 -04:00
|
|
|
console.log("# ---------------");
|
2020-07-13 08:03:56 -04:00
|
|
|
errors.forEach(function (error, index) {
|
|
|
|
if (index > 0) {
|
2020-08-23 19:39:57 -04:00
|
|
|
console.log("#");
|
2020-07-13 08:03:56 -04:00
|
|
|
}
|
2020-08-23 19:39:57 -04:00
|
|
|
error.toString().split("\n").forEach(function (line) {
|
|
|
|
console.log("# " + line);
|
|
|
|
});
|
2020-07-13 08:03:56 -04:00
|
|
|
});
|
|
|
|
}
|
2020-08-23 19:39:57 -04:00
|
|
|
console.log("# ---------------");
|
2020-07-13 08:03:56 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
runner.on('test', function (test) {
|
|
|
|
});
|
|
|
|
runner.on('fail', function (test, error) {
|
|
|
|
fails++;
|
|
|
|
if (fails < 10) {
|
|
|
|
errors.push("Error #" + errors.length + " (" + test.title + "): " + error.message + "\n" + error.stack);
|
|
|
|
log("!");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
runner.on('pass', function (test) {
|
|
|
|
});
|
|
|
|
runner.on('pending', function (test) {
|
|
|
|
log("?");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.ReporterKeepAlive = ReporterKeepAlive;
|
|
|
|
//# sourceMappingURL=reporter-keepalive.js.map
|