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 test cases for setUnrefTimeout. #20945

Closed
wants to merge 12 commits into from
Closed

Conversation

kakts
Copy link
Contributor

@kakts kakts commented May 24, 2018

Summary

Added some test cases for setUnrefTimeout in lib/internal/timers.js

This PR improves the test coverage of it.
https://coverage.nodejs.org/coverage-9a02de7084e3f3c9/root/internal/timers.js.html#L92

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label May 24, 2018
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 good

Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @kakts. I think a few small changes are needed before we get it landed.

I don't think this really belongs in this file. The refresh test for each of these isn't needed. I would create a new file test-timers-setunreftimeout.js or something similar.

test/parallel/test-timers-refresh.js Outdated Show resolved Hide resolved
test/parallel/test-timers-refresh.js Outdated Show resolved Hide resolved
@kakts
Copy link
Contributor Author

kakts commented May 29, 2018

@apapirovski
I'll move these test cases to test-timers-setunreftimeout.js.

@kakts
Copy link
Contributor Author

kakts commented May 31, 2018

I moved test cases to test/parallel/test-timers-setunreftimeout.js.
And also refactored them.

test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
@hiroppy hiroppy added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Jun 1, 2018
@kakts
Copy link
Contributor Author

kakts commented Jun 1, 2018

@apapirovski Thank you for the reviewing. I fixed them.

Copy link
Contributor

@Fishrock123 Fishrock123 left a comment

Choose a reason for hiding this comment

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

The tests do not pass. Please run ./configure && make -j4 test on your local machine!

test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
@kakts
Copy link
Contributor Author

kakts commented Jun 3, 2018

I fixed them again. @Fishrock123
Thank you for reviewing.

test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
@Fishrock123 Fishrock123 dismissed their stale review August 7, 2018 15:52

I think my review was addressed

@lundibundi
Copy link
Member

ping @kakts.

@kakts
Copy link
Contributor Author

kakts commented Aug 30, 2018

@lundibundi Thank you for the review.
I'll check them.

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

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

LGTM.

test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
test/parallel/test-timers-setunreftimeout.js Outdated Show resolved Hide resolved
@lundibundi
Copy link
Member

ping @apapirovski.

@kakts
Copy link
Contributor Author

kakts commented Sep 18, 2018

@lundibundi Thank you for your review.
I fixed them.

Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

This is still unnecessarily complicated and brittle (and didn't incorporate changes based on my earlier feedback). I've left some comments on what needs to be changed.

for (const arg of args) {
results.push(arg);
}
}), 1, ...inputArgs);
Copy link
Member

@apapirovski apapirovski Oct 15, 2018

Choose a reason for hiding this comment

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

clearTimeout(testTimer); here (after line 39, inside the function body).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! But if I fix this as you requested, it occures an error.
I fixed as below
ce868dd

}), 1, ...inputArgs);

const testTimer = setTimeout(common.mustCall(() => {
for (let k = 0; k < maxArgsNum; k++) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of populating results, just do the check in the first timeout. Then this timeout shouldn't have a body. Literally just const testTimer = setTimeout(common.mustCall(), 1);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!
I've fixed it.

`actual ${args.length}`
);
for (const arg of args) {
results.push(arg);
Copy link
Member

Choose a reason for hiding this comment

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

Just check the results here instead of populating an array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I'll fix not populating an array.

@Trott
Copy link
Member

Trott commented Nov 18, 2018

@kakts Are you able to address the remaining review comments?

@apapirovski If @kakts is not available to finish this, are your requests sufficiently narrow that you can add them via a fixup commit or something?

@kakts
Copy link
Contributor Author

kakts commented Nov 18, 2018

@Trott @apapirovski
Very sorry for late my fixing.
I've fixed ce868dd

@kakts
Copy link
Contributor Author

kakts commented Nov 18, 2018

commit title lint emmitted an error.
https://github.com/nodejs/node/blob/master/.travis.yml#L7-L14

So I will made a new PR.

test: add test cases for setUnrefTimeout.
+ npx -q core-validate-commit --no-validate-metadata https://api.github.com/repos/nodejs/node/commits/50d63c94774b6cacae78d1da03d6ca7219ff3fe9
  ✖  50d63c94774b6cacae78d1da03d6ca7219ff3fe9
     ✔  0:0      skipping fixes-url                        fixes-url
     ✔  0:0      blank line after title                    line-after-title
     ✔  0:0      line-lengths are valid                    line-length
     ✔  0:0      valid subsystems                          subsystem
     ✖  0:41     Do not use punctuation at end of title.   title-format
     ✔  0:0      Title is <= 50 columns.                   title-length

@refack
Copy link
Contributor

refack commented Nov 18, 2018

@kakts no need. It's easily fixable while landing the commit.

@Trott
Copy link
Member

Trott commented Dec 4, 2018

/ping @apapirovski Have your comments been adequately addressed? And if so, can you remove your request for changes?

@Trott
Copy link
Member

Trott commented Dec 4, 2018

@Trott
Copy link
Member

Trott commented Dec 5, 2018

Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19216/ ✔️

@shisama
Copy link
Contributor

shisama commented Mar 9, 2019

@apapirovski Could you review if your comments have been addressed?

@kakts
Copy link
Contributor Author

kakts commented Jun 13, 2019

Hi! How about this PR?
I'd fixed for some review comments already.

Could you check them again?

Copy link
Contributor

@Fishrock123 Fishrock123 left a comment

Choose a reason for hiding this comment

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

This looks fine to me. I've started a new CI run.

@nodejs-github-bot
Copy link
Collaborator

}

const timer = setUnrefTimeout(common.mustCall((...args) => {
// check the number of arguments passed to this callback.
Copy link
Contributor

Choose a reason for hiding this comment

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

Linter wants this to be capitalized (make -j4 lint)

Suggested change
// check the number of arguments passed to this callback.
// Check the number of arguments passed to this callback.

const maxArgsNum = 4;
for (let i = 0; i < maxArgsNum; i++) {
const inputArgs = [];
// set the input argument params
Copy link
Contributor

Choose a reason for hiding this comment

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

Linter wants this to be capitalized (make -j4 lint)

Suggested change
// set the input argument params
// Set the input argument params

Copy link
Contributor

@Fishrock123 Fishrock123 left a comment

Choose a reason for hiding this comment

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

Hmm. The test fails. Here is the CI output:

AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

  Comparison {
    code: 'ERR_INVALID_CALLBACK',
+   message: 'Callback must be a function. Received undefined',
-   message: 'Callback must be a function',
    type: [Function: TypeError]
  }
    at new AssertionError (internal/assert/assertion_error.js:418:11)
    at Object.innerFn (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/common/index.js:617:15)
    at expectedException (assert.js:645:26)
    at expectsError (assert.js:770:3)
    at Function.throws (assert.js:819:3)
    at Object.expectsError (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/common/index.js:629:12)
    at Object.<anonymous> (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/parallel/test-timers-setunreftimeout.js:10:10)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:811:32) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: [NodeError],
  expected: [Object],
  operator: 'common.expectsError'
}

@kakts
Copy link
Contributor Author

kakts commented Oct 11, 2019

@Fishrock123 Thank you for reviewing! I'll fix them again.

@nodejs-github-bot
Copy link
Collaborator

@gireeshpunathil
Copy link
Member

@apapirovski @Fishrock123 PTAL

@BridgeAR BridgeAR force-pushed the master branch 2 times, most recently from 8ae28ff to 2935f72 Compare May 31, 2020 12:20
@jasnell jasnell added the stalled Issues and PRs that are stalled. label Jun 19, 2020
@jasnell
Copy link
Member

jasnell commented Jun 25, 2020

This has not been updated in a while and has not made progress. Closing but can reopen if someone wants to pick it up again.

@jasnell jasnell closed this Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stalled Issues and PRs that are stalled. test Issues and PRs related to the tests. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
Projects
None yet
Development

Successfully merging this pull request may close these issues.