GeezerVison is showing github.com — test: improve child_process test coverage by chiiia12 · Pull Request #11278 · nodejs/node
Conversation
This PR improves child_process coverage (maybe cover statement 100%).
This is my first contribution, please review.
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)
N/A
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I'm not sure that the changes to test-child-process-exec-timeout.js and test-child-process-spawn-typeerror.js actually buy us anything.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@cjihrig
Currently, we are getting started to learn how to contribute node.js core in my company. I am teaching how-to-contribute and suggest contribution point. So I answered about that.
According to child_process coverage report ,
we found 3 uncovered blocks.
- child_process.fork option, stdio: ignore is not passed yet.
- child_process throws exception when kill signal is invalid.
- child_process.execFile can add arguments array but in current test the array is always empty.
so we just add those 3 tests.
|
jasnell and ericmdantas reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
child_process throws exception when kill signal is invalid.
I don't think the tests in this PR address that. I have a PR for that in #11038. I haven't landed it yet because I think there is an issue somewhere with killing child processes on Windows.
child_process.execFile can add arguments array but in current test the array is always empty.
Again, I don't think this PR addresses that. The changes to test-child-process-spawn-typeerror.js call spawn(), not execFile().
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@cjihrig
I don't think the tests in this PR address that. I have a PR for that in #11038.
we are checking to add console.log at the lines.
function kill() {
if (child.stdout)
child.stdout.destroy();
if (child.stderr)
child.stderr.destroy();
killed = true;
try {
child.kill(options.killSignal);
} catch (e) {
console.log(`caught on the kill signal: ${options.killSignal} `, e);
ex = e;
exithandler();
}
}
we have got the message like that. so I think we can pass the blocks.
$ node test/parallel/test-child-process-exec-timeout.js
caught on the kill signal: SIGUNDEF Error: Unknown signal: SIGUNDEF
at ChildProcess.kill (internal/child_process.js:375:11)
at kill (child_process.js:265:13)
at Timeout.delayedKill [as _onTimeout] (child_process.js:275:7)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
However, your PR will also reach here. we don't have an opinion which PR is better. if your PR will be merged before this PR, we will remove this test.
Again, I don't think this PR addresses that. The changes to test-child-process-spawn-typeerror.js call spawn(), not execFile().
hmm. this one is our failure, we need to fix about that. We will fix this soon. thank you.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cjihrig
commented
Feb 11, 2017
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
we are checking to add console.log at the lines.
Apologies. There is currently no input validation on the kill signal for execFile(). Ideally, it should be using the validateKillSignal() function used by spawnSync(), but that causes some test failures. Some work is needed to improve consistency there.
EDIT: #10423 is relevant to that test, as it would eliminate the code coverage.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@cjihrig
Yes, validateKillSignal for execFile is better. But the function changes would be better to discuss another PR. If we should wait for the function changes and #10423 , we can drop the undefined signal test. If you suggest so, we will drop.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@yosuke-furukawa I would drop the changes in test-child-process-exec-timeout.js. Those checks will become obsolete in #10423.
The changes in test-child-process-ignore-stdio.js add the missing code coverage, but I don't think it actually tests the code it's covering. For example, I can change the stdio option to a valid option other than 'ignore', and the test still passes.
The changes in test-child-process-spawn-typeerror.js should be moved to a different test file IMO. Because the code you're adding coverage for updates the cmd variable, some assertions should be added for the error object's message and cmd properties at a minimum.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
There hasn't been any activity here. I'm closing this. Feel free to reopen (or ping a collaborator).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jul 6, 2023
This was referenced Dec 10, 2023
This was referenced Dec 10, 2023
This was referenced May 16, 2024
Reviewers
jasnell
jasnell approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
child_process
Issues and PRs related to the child_process subsystem.
stalled
Issues and PRs manually marked as stalled and scheduled for automatic closure.
test
Issues and PRs related to Node.js core tests and test infrastructure.
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.
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.
|