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 : updated test to use common.mustCall #17437

Closed
wants to merge 1 commit into from
Closed

test : updated test to use common.mustCall #17437

wants to merge 1 commit into from

Conversation

mithunsasidharan
Copy link
Contributor

@mithunsasidharan mithunsasidharan commented Dec 3, 2017

refactored test case in test-http-res-write-end-dont-take-array to use common.mustCall as per issue #17169

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 3, 2017
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Dec 3, 2017
res.write('string');
// write should accept buffer
res.write(Buffer.from('asdf'));
const countdown = new Countdown(2, () => res.end(Buffer.from('asdf')));
Copy link
Member

Choose a reason for hiding this comment

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

This will no longer do what it claims to as the countdown is redeclared on each request. It will never go below 1 which means the callback will never fire.

In general, this test would be better if rewritten without Countdown and instead by using .once('request') with common.mustCall for the first test that would then declare on('request') with common.mustCall for the 2nd test.

Something like this basically:

server.once('request', common.mustCall((req, res) => {
  server.on('request', common.mustCall((req, res) => {
    res.end(Buffer.from('asdf'));	
  }));
  // 1st test case code here
}));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@apapirovski : Thanks for the feedback. I've updated the PR with the changes and also shortened the commit message. Kindly review the PR now. Thanks !

@mithunsasidharan mithunsasidharan changed the title test : updated test cases in test-http-res-write-end-dont-take-array to use countdown test : updated test to use common.mustCall Dec 3, 2017
@apapirovski
Copy link
Member

Copy link
Contributor

@maclover7 maclover7 left a comment

Choose a reason for hiding this comment

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

One quick note

@@ -23,41 +23,37 @@
require('../common');
const assert = require('assert');
const http = require('http');
const common = require('../common');
Copy link
Contributor

Choose a reason for hiding this comment

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

See line 23 -- common has already been required, but just not set to a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maclover7 : Thanks for the feedback. I've updated the PR with the changes. Kindly review now and update the CI Checks. Thanks !

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

The inclusion of common must be the first module loaded. Otherwise, it does not protect against leaked globals from other modules.

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM once common is moved to be the first module loaded and if CI is OK.

@mithunsasidharan
Copy link
Contributor Author

@Trott : Thanks for the feedback. I've moved up common to be the first module loaded. Kindly review the PR now. Thanks !

@maclover7
Copy link
Contributor

@maclover7 maclover7 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 5, 2017
@mithunsasidharan
Copy link
Contributor Author

@maclover7 : Curious why test/linux-one failed ?

@maclover7
Copy link
Contributor

@mithunsasidharan It looks like it's an unrelated failure, and the rest of the CI is green, so things should be okay.

@mithunsasidharan
Copy link
Contributor Author

@apapirovski : Can you please land this ? Thanks a lot !

@apapirovski
Copy link
Member

Landed in bb59063

Thank you for your contribution!

@apapirovski apapirovski closed this Dec 6, 2017
apapirovski pushed a commit that referenced this pull request Dec 6, 2017
PR-URL: #17437
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@mithunsasidharan mithunsasidharan deleted the pr_7 branch December 6, 2017 14:31
@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 7, 2017
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
PR-URL: #17437
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
PR-URL: #17437
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 12, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17437
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17437
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.