From 9fa39a091b4847e933871677d412a749dad26d91 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Fri, 23 Aug 2024 10:59:17 -0400 Subject: [PATCH] make CommandWatcher dump logs at shutdown() when a command has failed --- tests/scenarios/helpers/command-watcher.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/scenarios/helpers/command-watcher.ts b/tests/scenarios/helpers/command-watcher.ts index ca9d145eb..817ec1cf1 100644 --- a/tests/scenarios/helpers/command-watcher.ts +++ b/tests/scenarios/helpers/command-watcher.ts @@ -105,6 +105,7 @@ export default class CommandWatcher { async shutdown(): Promise { if (this.exitCode != null) { + this.maybeEmitLogs(); return; } @@ -119,6 +120,14 @@ export default class CommandWatcher { }); await this.waitForExit(); + this.maybeEmitLogs(); + } + + private maybeEmitLogs() { + if (this.exitCode !== 0) { + console.error(`CommandWatcher saw non-zero exit, dumping logs:`); + console.error(this.lines.join('\n')); + } } async waitForExit(): Promise {