From ba784e87b4a07a9980183f748687c5163ab4847a Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Thu, 2 Feb 2023 22:00:06 +0200 Subject: [PATCH] test_runner: fix missing test diagnostics PR-URL: https://github.com/nodejs/node/pull/46450 Backport-PR-URL: https://github.com/nodejs/node/pull/46839 Fixes: https://github.com/nodejs/node/issues/45911 Reviewed-By: Colin Ihrig Reviewed-By: Antoine du Hamel --- lib/internal/test_runner/runner.js | 5 ++++- test/message/test_runner_output_cli.out | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 875cc4247262c4..cab4bfd4d9edca 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -139,9 +139,12 @@ class FileTest extends Test { return secondSpaceIndex === -1 && ArrayPrototypeIncludes(kDiagnosticsFilterArgs, StringPrototypeSlice(comment, 0, firstSpaceIndex)); } - #handleReportItem({ kind, node, nesting = 0 }) { + #handleReportItem({ kind, node, comments, nesting = 0 }) { nesting += 1; + if (comments) { + ArrayPrototypeForEach(comments, (comment) => this.reporter.diagnostic(nesting, this.name, comment)); + } switch (kind) { case TokenKind.TAP_VERSION: // TODO(manekinekko): handle TAP version coming from the parser. diff --git a/test/message/test_runner_output_cli.out b/test/message/test_runner_output_cli.out index 525f8db3c885e3..cc9c07f4c5c409 100644 --- a/test/message/test_runner_output_cli.out +++ b/test/message/test_runner_output_cli.out @@ -57,6 +57,7 @@ TAP version 13 --- duration_ms: * ... + # this test should pass # Subtest: sync throw fail not ok 8 - sync throw fail --- @@ -204,6 +205,7 @@ TAP version 13 * * ... + # this subtest should make its parent test fail 1..1 not ok 21 - subtest sync throw fail --- @@ -365,6 +367,7 @@ TAP version 13 --- duration_ms: * ... + # \#diagnostic # Subtest: callback pass ok 41 - callback pass ---