Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: delegate stderr and stdout formatting to reporter #48045

Merged
merged 1 commit into from
May 23, 2023

Conversation

HinataKah0
Copy link
Contributor

@HinataKah0 HinataKah0 commented May 17, 2023

Introduce new TestsStream events test:stderr and test:stdout
to delegate stderr and stdout (e.g. console.log()) formatting
to the reporter. And patch existing reporters to:

  • Spec: output the message as it is
  • TAP: stay the same with existing test:diagnostic

Fixes: #48011

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 17, 2023
doc/api/test.md Outdated Show resolved Hide resolved
doc/api/test.md Show resolved Hide resolved
doc/api/test.md Show resolved Hide resolved
@@ -285,7 +285,7 @@ class FileTest extends Test {
const message = messages[i];
this.addToReport({
__proto__: null,
type: 'test:diagnostic',
type: 'test:stdout',
data: { __proto__: null, nesting: 0, file: this.name, message },
Copy link
Member

@MoLow MoLow May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you have mentioned, nesting is redundant here.
also, I think we should stop breaking this into lines and delegate that to the TAP reporter (and leave as is in spec reporter) - but that dosnt have to happen in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should stop breaking this into lines and delegate that to the TAP reporter (and leave as is in spec reporter)

Sorry I don't get the spec reporter part. By "leaving as it is" are you referring to printing \n as \\n?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I don't get the spec reporter part. By "leaving as it is" are you referring to printing \n as \n?

I was referring to the output being split into lines before passing it to the reporter:

const messages = RegExpPrototypeSymbolSplit(kSplitLine, nonSerialized.toString('utf-8'));

but as written, it is also ok to not include it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address it in separate PR 👍

@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label May 18, 2023
@HinataKah0
Copy link
Contributor Author

hopefully, with #48045 we can make node --test test.js behave the same as node test.js in terms of console logs

Hi @MoLow , so we want to make the output format of both with & without --test same, right? Maybe without the prefix # or the symbol?

@HinataKah0 HinataKah0 force-pushed the tests-stream-new-event branch from 6e503ca to 3473edc Compare May 19, 2023 02:30
doc/api/test.md Outdated Show resolved Hide resolved
doc/api/test.md Outdated Show resolved Hide resolved
@MoLow
Copy link
Member

MoLow commented May 19, 2023

so we want to make the output format of both with & without --test same, right? Maybe without the prefix # or the symbol?

I think TAP should stay the same as today, and spec should just pipe the original data. that is the goal

@HinataKah0 HinataKah0 force-pushed the tests-stream-new-event branch from 3473edc to 16f1020 Compare May 19, 2023 14:58
@HinataKah0
Copy link
Contributor Author

HinataKah0 commented May 19, 2023

For the Spec reporter, it looks like this:
Screenshot 2023-05-19 at 10 57 10 PM

I don't think we have any test for console.log Spec reporter because after I changed to output the original data as it is, it doesn't break any test.

@HinataKah0 HinataKah0 changed the title test_runner: delegate stdout formatting to reporter test_runner: delegate stderr and stdout formatting to reporter May 19, 2023
Introduce new `TestsStream` events `test:stderr` and `test:stdout`
to delegate `stderr` and `stdout` (e.g. `console.log()`) formatting
to the reporter. And patch existing reporters to:
- Spec: output the message as it is
- TAP: stay the same with existing `test:diagnostic`
@HinataKah0 HinataKah0 force-pushed the tests-stream-new-event branch from 16f1020 to 67f3543 Compare May 21, 2023 09:02
### Event: `'test:stderr'`

* `data` {Object}
* `file` {string} The path of the test file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the test:diagnostic event, this can also be undefined. Is that possible for these new events?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. test:diagnostic can be produced inside the REPL. these new events are only useful with --test

@MoLow MoLow requested a review from cjihrig May 22, 2023 15:51
@MoLow MoLow added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels May 22, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 22, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label May 23, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 23, 2023
@nodejs-github-bot nodejs-github-bot merged commit 1229a22 into nodejs:main May 23, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 1229a22

@HinataKah0 HinataKah0 deleted the tests-stream-new-event branch May 23, 2023 13:37
targos pushed a commit that referenced this pull request May 30, 2023
Introduce new `TestsStream` events `test:stderr` and `test:stdout`
to delegate `stderr` and `stdout` (e.g. `console.log()`) formatting
to the reporter. And patch existing reporters to:
- Spec: output the message as it is
- TAP: stay the same with existing `test:diagnostic`

PR-URL: #48045
Fixes: #48011
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@targos targos mentioned this pull request Jun 4, 2023
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
Introduce new `TestsStream` events `test:stderr` and `test:stdout`
to delegate `stderr` and `stdout` (e.g. `console.log()`) formatting
to the reporter. And patch existing reporters to:
- Spec: output the message as it is
- TAP: stay the same with existing `test:diagnostic`

PR-URL: #48045
Fixes: #48011
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MoLow pushed a commit to MoLow/node that referenced this pull request Jul 6, 2023
Introduce new `TestsStream` events `test:stderr` and `test:stdout`
to delegate `stderr` and `stdout` (e.g. `console.log()`) formatting
to the reporter. And patch existing reporters to:
- Spec: output the message as it is
- TAP: stay the same with existing `test:diagnostic`

PR-URL: nodejs#48045
Fixes: nodejs#48011
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Introduce new `TestsStream` events `test:stderr` and `test:stdout`
to delegate `stderr` and `stdout` (e.g. `console.log()`) formatting
to the reporter. And patch existing reporters to:
- Spec: output the message as it is
- TAP: stay the same with existing `test:diagnostic`

PR-URL: nodejs#48045
Fixes: nodejs#48011
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Introduce new `TestsStream` events `test:stderr` and `test:stdout`
to delegate `stderr` and `stdout` (e.g. `console.log()`) formatting
to the reporter. And patch existing reporters to:
- Spec: output the message as it is
- TAP: stay the same with existing `test:diagnostic`

PR-URL: nodejs#48045
Fixes: nodejs#48011
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test Runner: delegate arbitrary output formatting to each reporter
5 participants