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: improve code coverage for streams/duplexify #41862

Merged

Conversation

ErickWendel
Copy link
Member

@ErickWendel ErickWendel commented Feb 5, 2022

Improve code coverage for streams duplexify.js

Refs:

I would add that those lines are unreachable:

  • duplexify.js.html#L71: We already validated all types of streams it'll never call the isNodeStream function
  • duplexify.js.html#L199: all data types were checked on the previous statements. The only values that could throw here would be primitive values but the assert won't let it run.
  • duplexify.js.html#L161: it'll never be undefined as the statement checks if typeof body?.readable === 'object'
  • duplexify.js.html#L166: it'll never be undefined as the statement checks if typeof body?.writable === 'object'

In those cases, what could I do to cover it?

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Feb 5, 2022
@Trott
Copy link
Member

Trott commented Feb 5, 2022

If we have to use --expose-internals then that's fine, but it would be preferable if there was a way to cover the lines using public APIs.

@Trott
Copy link
Member

Trott commented Feb 5, 2022

If we have to use --expose-internals then that's fine, but it would be preferable if there was a way to cover the lines using public APIs.

(We can also land this and try to refactor things later to use public APIs where possible.)

@Trott
Copy link
Member

Trott commented Feb 5, 2022

In those cases, what could I do to cover it?

If could is unreachable, you can delete it. If you want to be cautious, you can replace it with an internal assertion. (https://github.com/nodejs/node/blob/e46c680bf2b211bbd52cf959ca17ee98c7f657f5/lib/internal/cluster/shared_handle.js is an example of something that uses the internal assertion.)

@ErickWendel
Copy link
Member Author

If we have to use --expose-internals then that's fine, but it would be preferable if there was a way to cover the lines using public APIs.

Just updated it using Public APIs

@ErickWendel
Copy link
Member Author

In those cases, what could I do to cover it?

If could is unreachable, you can delete it. If you want to be cautious, you can replace it with an internal assertion. (https://github.com/nodejs/node/blob/e46c680bf2b211bbd52cf959ca17ee98c7f657f5/lib/internal/cluster/shared_handle.js is an example of something that uses the internal assertion.)

Perfect, I'll create another PR to land this, ok?

@Mesteery Mesteery added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 7, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 7, 2022
@nodejs-github-bot
Copy link
Collaborator

@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 10, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 10, 2022
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Feb 11, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 11, 2022
@nodejs-github-bot nodejs-github-bot merged commit 0185464 into nodejs:master Feb 11, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 0185464

bengl pushed a commit to bengl/node that referenced this pull request Feb 21, 2022
PR-URL: nodejs#41862
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
bengl pushed a commit to bengl/node that referenced this pull request Feb 21, 2022
PR-URL: nodejs#41862
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@bengl bengl mentioned this pull request Feb 21, 2022
bengl pushed a commit that referenced this pull request Feb 22, 2022
PR-URL: #41862
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@danielleadams
Copy link
Contributor

@ErickWendel this breaks tests when landing in v16.x-staging. Do you mind creating a backport PR for the v16.x line? Thank you

@ErickWendel
Copy link
Member Author

@ErickWendel this breaks tests when landing in v16.x-staging. Do you mind creating a backport PR for the v16.x line? Thank you

Heyy. Sure! Do you have an example of how to do it? I'm not sure if it's just to make it works on the v16.x

targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #41862
Backport-PR-URL: #42788
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #41862
Backport-PR-URL: #42788
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#41862
Backport-PR-URL: nodejs/node#42788
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
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. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.