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: add common.mustCall #14262

Closed
wants to merge 3 commits into from
Closed

Conversation

Suixinlei
Copy link
Contributor

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 Jul 16, 2017
@bengl bengl added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Jul 16, 2017
@TimothyGu
Copy link
Member

@Trott
Copy link
Member

Trott commented Jul 16, 2017

This doesn't look quite correct.

Instead of wrapping process.on('exit',...) in common.mustCall(), you probably want to remove process.on('exit',...) entirely and replace it with common.mustCall() usage.

@Trott
Copy link
Member

Trott commented Jul 16, 2017

(continued) So, for example, remove this:

process.on('exit', () => {
  assert.strictEqual(requestCount, 3);
});

...and add code that instead checks that whatever function is incrementing requestCount is called exactly 3 times:

const server = http.createServer(common.mustCall((req, res) => {
  requestCount++;
  res.end();
}, 3));

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.

(See comments.)

@TimothyGu TimothyGu added code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. and removed code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. labels Jul 16, 2017
@Suixinlei
Copy link
Contributor Author

@Trott I have take a change, please take a look

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 if CI is green!

@Suixinlei
Copy link
Contributor Author

@Trott I have change again, remove res.end() in serverNoEndKeepAliveTimeoutWithPipeline . please take a look again~

@Trott
Copy link
Member

Trott commented Jul 16, 2017

Still LGTM, I think!
Thanks for the contribution! 🎉

@vsemozhetbyt
Copy link
Contributor

@Trott
Copy link
Member

Trott commented Jul 16, 2017

CI was green, but I canceled the Raspberry PI 1 run because of our CI backlog right now. This can land, though, IMO. Would prefer to fast-track it, but would want a few more Collaborator approvals first. However, even if no one else provides a review, this can land after being open for 72 hours.

const server = http.createServer((req, res) => {
requestCount++;
});
const server = http.createServer(common.mustCall((req, res) => {}, 3));
Copy link
Member

@jasnell jasnell Jul 17, 2017

Choose a reason for hiding this comment

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

Since the function inside the mustCall() is a non-op, this can be shortened to just:

const server = http.createServer(common.mustCall(3));

});
const server = https.createServer(
serverOptions,
common.mustCall((req, res) => {}, 3));
Copy link
Member

Choose a reason for hiding this comment

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

ditto here...

const server = http2.createServer(serverOptions, common.mustCall(3));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx, I have already simplify common.mustCall.this made test more readable. @jasnell

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@Trott
Copy link
Member

Trott commented Jul 26, 2017

@Trott
Copy link
Member

Trott commented Jul 26, 2017

Landed in 2e864df

Thanks for the contribution! 🎉

@Trott Trott closed this Jul 26, 2017
Trott pushed a commit to Trott/io.js that referenced this pull request Jul 26, 2017
PR-URL: nodejs#14262
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this pull request Jul 27, 2017
PR-URL: #14262
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.