test: add test cases for setUnrefTimeout.#20945
test: add test cases for setUnrefTimeout.#20945kakts wants to merge 12 commits intonodejs:masterfrom
Conversation
apapirovski
left a comment
There was a problem hiding this comment.
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.
|
@apapirovski |
|
I moved test cases to test/parallel/test-timers-setunreftimeout.js. |
|
@apapirovski Thank you for the reviewing. I fixed them. |
Fishrock123
left a comment
There was a problem hiding this comment.
The tests do not pass. Please run ./configure && make -j4 test on your local machine!
|
I fixed them again. @Fishrock123 |
|
ping @kakts. |
|
@lundibundi Thank you for the review. |
|
ping @apapirovski. |
|
@lundibundi Thank you for your review. |
apapirovski
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
clearTimeout(testTimer); here (after line 39, inside the function body).
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Thank you!
I've fixed it.
| `actual ${args.length}` | ||
| ); | ||
| for (const arg of args) { | ||
| results.push(arg); |
There was a problem hiding this comment.
Just check the results here instead of populating an array.
There was a problem hiding this comment.
Thank you. I'll fix not populating an array.
|
@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? |
|
@Trott @apapirovski |
|
commit title lint emmitted an error. So I will made a new PR. |
|
@kakts no need. It's easily fixable while landing the commit. |
|
/ping @apapirovski Have your comments been adequately addressed? And if so, can you remove your request for changes? |
|
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19216/ ✔️ |
|
@apapirovski Could you review if your comments have been addressed? |
|
Hi! How about this PR? Could you check them again? |
Fishrock123
left a comment
There was a problem hiding this comment.
This looks fine to me. I've started a new CI run.
| } | ||
|
|
||
| const timer = setUnrefTimeout(common.mustCall((...args) => { | ||
| // check the number of arguments passed to this callback. |
There was a problem hiding this comment.
Linter wants this to be capitalized (make -j4 lint)
| // 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 |
There was a problem hiding this comment.
Linter wants this to be capitalized (make -j4 lint)
| // set the input argument params | |
| // Set the input argument params |
Fishrock123
left a comment
There was a problem hiding this comment.
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'
}
|
@Fishrock123 Thank you for reviewing! I'll fix them again. |
|
@apapirovski @Fishrock123 PTAL |
8ae28ff to
2935f72
Compare
|
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. |
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), orvcbuild test(Windows) passes