test_runner: remove stdout and stderr from error#45592
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom Nov 25, 2022
Merged
test_runner: remove stdout and stderr from error#45592nodejs-github-bot merged 1 commit intonodejs:mainfrom
nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred.
targos
approved these changes
Nov 23, 2022
Member
|
Now, arbitrary output on stderr is swallowed, I think we should at least pipe it to the parent process stderr. |
Contributor
Author
From my testing stderr shows up as TAP comments because the child process stderr is (incorrectly) piped into the TAP parser. I also have a follow up PR that stops stderr from being piped to the parser and instead just interprets the lines of stderr as unknown TAP tokens (diff below) - I just have to write a test for it. diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js
index 3f7134c6cd..eb73a46e55 100644
--- a/lib/internal/test_runner/runner.js
+++ b/lib/internal/test_runner/runner.js
@@ -246,16 +246,25 @@ function runTestFile(path, root, inspectPort, filesWatcher) {
rl.on('line', (line) => {
if (isInspectorMessage(line)) {
process.stderr.write(line + '\n');
+ return;
}
+
+ // stderr cannot be treated as TAP, per the spec. However, we want to
+ // surface stderr lines as TAP diagnostics to improve the DX. Inject
+ // each line into the test output as an unknown token as if it came
+ // from the TAP parser.
+ const node = {
+ kind: TokenKind.UNKNOWN,
+ node: {
+ value: line,
+ },
+ };
+
+ subtest.addToReport(node);
});
}
const parser = new TapParser();
- child.stderr.pipe(parser).on('data', (ast) => {
- if (ast.lexeme && isInspectorMessage(ast.lexeme)) {
- process.stderr.write(ast.lexeme + '\n');
- }
- });
child.stdout.pipe(parser).on('data', (ast) => {
subtest.addToReport(ast);
diff --git a/lib/internal/util/inspector.js b/lib/internal/util/inspector.js
index 038479b173..c7f18ffdb6 100644
--- a/lib/internal/util/inspector.js
+++ b/lib/internal/util/inspector.js
@@ -16,7 +16,7 @@ const { validatePort } = require('internal/validators');
const kMinPort = 1024;
const kMaxPort = 65535;
const kInspectArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
-const kInspectMsgRegex = /Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\/|Debugger attached|Waiting for the debugger to disconnect\.\.\./;
+const kInspectMsgRegex = /Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\/|For help, see: https:\/\/nodejs\.org\/en\/docs\/inspector|Debugger attached|Waiting for the debugger to disconnect\.\.\./;
const _isUsingInspector = new SafeWeakMap();
function isUsingInspector(execArgv = process.execArgv) { |
MoLow
approved these changes
Nov 23, 2022
Collaborator
Collaborator
Collaborator
|
Landed in fec0fbc |
20 tasks
Merged
ErickWendel
pushed a commit
to ErickWendel/node
that referenced
this pull request
Nov 30, 2022
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: nodejs#45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos
pushed a commit
that referenced
this pull request
Dec 12, 2022
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: #45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams
pushed a commit
that referenced
this pull request
Dec 30, 2022
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: #45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams
pushed a commit
that referenced
this pull request
Dec 30, 2022
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: #45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams
pushed a commit
that referenced
this pull request
Jan 3, 2023
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: #45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams
pushed a commit
that referenced
this pull request
Jan 4, 2023
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: #45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams
pushed a commit
that referenced
this pull request
Jan 5, 2023
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: #45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
MoLow
pushed a commit
to MoLow/node-core-test
that referenced
this pull request
Feb 2, 2023
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: nodejs/node#45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> (cherry picked from commit fec0fbc333c58e6ebbd2322f5120830fda880eb0)
MoLow
pushed a commit
to MoLow/node-core-test
that referenced
this pull request
Feb 2, 2023
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: nodejs/node#45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> (cherry picked from commit fec0fbc333c58e6ebbd2322f5120830fda880eb0)
MoLow
pushed a commit
to MoLow/node-core-test
that referenced
this pull request
Feb 2, 2023
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred. PR-URL: nodejs/node#45592 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> (cherry picked from commit fec0fbc333c58e6ebbd2322f5120830fda880eb0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CLI test runner parses the TAP output from child processes now and displays it. This commit removes a previous workaround for displaying child process stdout and stderr when tests failures occurred.