GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: remove duplicate test about warning in lib/net.js by kuriyosh · Pull Request #41307 · nodejs/node

Conversation

@kuriyosh

@kuriyosh kuriyosh commented Dec 24, 2021

Copy link
Copy Markdown
Contributor

test-net-server-simultaneous-accepts-produce-warning-once.js test a same code as test-net-deprecated-setsimultaneousaccepts.js.
So I remove test-net-server-simultaneous-accepts-produce-warning-once.js.

before coverage:
https://coverage.nodejs.org/coverage-895c3d937ea74faa/lib/net.js.html#L1761

after coverage:
Screen Shot 2021-12-24 at 11 38 37

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure. labels Dec 24, 2021
@kuriyosh kuriyosh changed the title test: remove duplicate test about deprecation warning test: remove duplicate test about warning in lib/net.js Dec 24, 2021
@Trott

Trott commented Dec 24, 2021

Copy link
Copy Markdown
Member

These tests are not quite the same. The test you left makes sure that the warning is emitted on the first call. The test you deleted makes sure that the warning is emitted only once even when the API is called twice. They can certainly be consolidated into a single test, but they do not quite test the same things.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kuriyosh

kuriyosh commented Dec 24, 2021

Copy link
Copy Markdown
Contributor Author

@Trott Thanks for your comment!
I didn't understand the purpose of these tests correctly.

Based on your comment, I think it is test-net-server-simultaneous-accepts-produce-warning-once.js that should be left.
Because, by running test-net-server-simultaneous-accepts-produce-warning-once.js, we can check if the warning is emitted and check the behavior of the second execution at the same time.
Could you review my PR again?

after coverage:
Screen Shot 2021-12-24 at 13 53 00

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Dec 24, 2021
View reviewed changes
Comment thread test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Dec 24, 2021

Copy link
Copy Markdown
Member

Because, by running test-net-server-simultaneous-accepts-produce-warning-once.js, we can check if the warning is emitted and check the behavior of the second execution at the same time. Could you review my PR again?

I've added some suggestions to try to make sure that the warning is called on the first invocation of the API and not on the second. (The way the test is written right now, I think it only checks that the warning is raised once but does not confirm it was the first call and not the second call. That's fine if the other test exists because the other tests confirms the warning is emitted on the first call. But if we're removing that other test, then maybe we should check that here too.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kuriyosh

kuriyosh commented Dec 24, 2021

Copy link
Copy Markdown
Contributor Author

Thank you for your smart solution!
@Trott 's code exactly check that DEP0121 is emitted only once.
I totaly agree with your suggestion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott
Trott force-pushed the remove-duplicate-net-test branch from 6b9fa28 to 28db916 Compare December 24, 2021 08:15
@kuriyosh @Trott
test: remove duplicate test about deprecation warning
7fa3e4e
@Trott
Trott force-pushed the remove-duplicate-net-test branch from 28db916 to 7fa3e4e Compare December 24, 2021 08:15
Trott
Trott approved these changes Dec 24, 2021
View reviewed changes
@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 24, 2021
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 24, 2021
@nodejs-github-bot

nodejs-github-bot commented Dec 24, 2021

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/41643/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Dec 24, 2021

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/41645/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Dec 24, 2021
lpinca
lpinca approved these changes Dec 24, 2021
View reviewed changes
@github-actions github-actions Bot mentioned this pull request Dec 25, 2021
CI Reliability 2021-12-25 nodejs/reliability#155
Open
19 tasks
aduh95
aduh95 reviewed Dec 25, 2021
View reviewed changes
Comment thread test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js Outdated
Comment on lines +11 to +13
process.on('warning', mustCall(() => {
process.on('warning', mustNotCall());
}));

@aduh95 aduh95 Dec 25, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

nit: this could be simplified as mustCall will check that the callback is only invoked once. We can also explicitly provide the number of calls we are expecting so it's clearer:

Suggested change
process.on('warning', mustCall(() => {
process.on('warning', mustNotCall());
}));
process.on('warning', mustCall(1));

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Dec 25, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@aduh95 Your suggestion is simpler, but is slightly more permissive than the code in this PR. The code in this PR guarantees that the first call of the API results in a warning and the second call does not. The change you suggest here will still result in a passing test if the first call does not result in a warning and the second one does. Admittedly, that's an edge case that is unlikely to happen. But I have a slight preference for the stricter checking here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@aduh95 aduh95 Dec 25, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don’t see how, the current code checks the 'warning' event is emitted once, but I don’t think it can know what API call triggered it either 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Dec 25, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don’t see how, the current code checks the 'warning' event is emitted once, but I don’t think it can know what API call triggered it either 🤔

Current code in master branch tests it by having two separate tests that are nearly identical. One test only calls the API once and makes sure that the warning is emitted once. The other test calls the API twice and makes sure that the warning is emitted once. Alone, that second test doesn't confirm that the warning happens on the first API call, but in combination with the first test, that is effectively checked.

This PR consolidates those two tests into a single test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Dec 25, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Oh, wait, or are you suggesting that there will be a problem if something else (like --pending-deprecations) causes warnings? Yeah, that's a valid concern and one we should address....

I'm wondering if we're actually best off just having two tests. :-D

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Dec 25, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@kuriyosh How would you feel about restoring both tests and adding a short comment in each one explaining why there are two different-but-very-similar tests?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kuriyosh kuriyosh Dec 26, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

In my understanding, the discussed concern is that this test fails if other warnings occur in a second call. (Please point me out if I'm wrong here.) I agree that we need to run test-net-deprecated-setsimultaneousaccepts.js to make sure that _setSimultaneousAccepts() does not emit other warnings.

On the other hand, test-net-server-simultaneous-accepts-produce-warning-once.js in master branch does not check whether if _setSimultaneousAccepts() emit DEP0121 in a second call. That test can be passed if second calling _setSimultaneousAccepts() emit DEP0121 because of the behavior of expectsWarning().
So, I think the change of test-net-server-simultaneous-accepts-produce-warning-once.js in this PR is needed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Dec 26, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

On the other hand, test-net-server-simultaneous-accepts-produce-warning-once.js in master branch does not check whether if _setSimultaneousAccepts() emit DEP0121 in a second call.

It does check. expectsWarning() will fail if it receives the warning more than once.

This exits with a failure status:

const {expectWarning} = require('./test/common');

expectWarning('foo', 'foo', 'foo');

This exits with success status:

const {expectWarning} = require('./test/common');

expectWarning('foo', 'foo', 'foo');

process.emitWarning('foo', 'foo', 'foo');

And this exits with a failure status again:

const {expectWarning} = require('./test/common');

expectWarning('foo', 'foo', 'foo');

process.emitWarning('foo', 'foo', 'foo');
process.emitWarning('foo', 'foo', 'foo');

One thing I notice while running these tests is that the error message is not great on that last example because const [ message, code ] = expected.shift(); (in test/common/index.js) does not accommodate the possibility that expected is an empty array and expected.shift() returns undefined:

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

So that's probably worth fixing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Dec 26, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

So that's probably worth fixing.

#41326

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kuriyosh kuriyosh Dec 26, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sorry, I misunderstood the behavior of expectWarning...
I totally agree on having two separate tests.
I have committed for adding comment in these test codes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Trott
Trott requested changes Dec 25, 2021
View reviewed changes

@Trott Trott left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Blocking for the moment on https://github.com/nodejs/node/pull/41307/files#r775147880.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot mentioned this pull request Dec 26, 2021
CI Reliability 2021-12-26 nodejs/reliability#156
Open
19 tasks
kuriyosh added 2 commits December 26, 2021 18:51
@kuriyosh
test: revert two test and add comments for each
c23d0e6
@kuriyosh
test: fix lint error
2045739
Trott
Trott reviewed Dec 26, 2021
View reviewed changes
Comment thread test/parallel/test-net-deprecated-setsimultaneousaccepts.js Outdated
Comment on lines +4 to +5
// This test checks that `_setSimultaneousAccepts` emit DEP0121 warning.
// Ref test-net-server-simultaneous-accepts-produce-warning-once.js

@Trott Trott Dec 26, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
// This test checks that `_setSimultaneousAccepts` emit DEP0121 warning.
// Ref test-net-server-simultaneous-accepts-produce-warning-once.js
// Test that DEP0121 is emitted on the first call of _setSimultaneousAccepts().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Trott
Trott reviewed Dec 26, 2021
View reviewed changes
Comment thread test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Dec 27, 2021
CI Reliability 2021-12-27 nodejs/reliability#157
Open
17 tasks
@kuriyosh
test: update comment for test description
6ef49ff
Trott
Trott approved these changes Dec 27, 2021
View reviewed changes
@Trott

Trott commented Dec 27, 2021

Copy link
Copy Markdown
Member

I don't see a label for this but the commit queue should not be used to land this because the commit message for the first commit in this PR is no longer accurate. (@kuriyosh If you want to force-push an updated commit message, or even squash the four commits here into a single commit, that would be great. But if not, it's no big deal for someone to do it when landing this.)

kuriyosh reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 approved these changes Dec 27, 2021
View reviewed changes
@aduh95
aduh95 merged commit 24f4f7f into nodejs:master Dec 27, 2021
This was referenced Dec 28, 2021
CI Reliability 2021-12-28 nodejs/reliability#158
Open
CI Reliability 2021-12-29 nodejs/reliability#159
Open
CI Reliability 2021-12-30 nodejs/reliability#160
Open
CI Reliability 2021-12-31 nodejs/reliability#161
Open
CI Reliability 2022-01-01 nodejs/reliability#162
Open
CI Reliability 2022-01-02 nodejs/reliability#163
Open
CI Reliability 2022-01-03 nodejs/reliability#164
Open
@github-actions github-actions Bot mentioned this pull request Jan 4, 2022
CI Reliability 2022-01-04 nodejs/reliability#165
Open
25 tasks
targos pushed a commit that referenced this pull request Jan 14, 2022
@kuriyosh @targos
test: add comments explaining _setSimultaneousAccepts deprecation tests
b2a87f7
PR-URL: #41307
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@targos targos mentioned this pull request Jan 16, 2022
v17.4.0 release proposal #41557
Merged
danielleadams pushed a commit that referenced this pull request Jan 31, 2022
@kuriyosh @danielleadams
test: add comments explaining _setSimultaneousAccepts deprecation tests
83bc50c
PR-URL: #41307
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
danielleadams pushed a commit that referenced this pull request Feb 1, 2022
@kuriyosh @danielleadams
test: add comments explaining _setSimultaneousAccepts deprecation tests
8d15bac
PR-URL: #41307
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@danielleadams danielleadams mentioned this pull request Feb 1, 2022
v16.14.0 proposal #41804
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lpinca lpinca lpinca approved these changes
@Trott Trott Trott approved these changes
@aduh95 aduh95 aduh95 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@kuriyosh @Trott @nodejs-github-bot @lpinca @aduh95
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.