From 052db56a2eb19027a38c52dfc84e03d47ad86df7 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 3 Nov 2021 11:57:48 -0700 Subject: [PATCH] Add an easy way to log to the terminal during browser tests. On the main thread call `driver.log` and the message will output in the terminal with the pdf id and the message. I've been using this a lot when trying to find certain PDFs or logging stats. --- test/driver.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/driver.js b/test/driver.js index 2eadf239e..266f969fd 100644 --- a/test/driver.js +++ b/test/driver.js @@ -466,6 +466,24 @@ var Driver = (function DriverClosure() { }, this.delay); }, + /** + * A debugging tool to log to the terminal while tests are running. + * XXX: This isn't currently referenced, but it's useful for debugging so + * do not remove it. + * + * @param {string} msg - The message to log, it will be prepended with the + * current PDF ID if there is one. + */ + log(msg) { + let id = this.browser; + const task = this.manifest[this.currentTask]; + if (task) { + id += `-${task.id}`; + } + + this._info(`${id}: ${msg}`); + }, + _nextTask() { let failure = "";