test: make sigint test to actually check child pid #1656
Merged
+52
−31
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.
The aim of this PR is to fix some issues in SIGINT test.
The problem
Due to combination of the following effects, the SIGINT test does not actually test what it is made for:
string.replace
method takes the child pid from incorrect parameter:nodemon/test/misc/sigint.test.js
Lines 16 to 22 in cd45d74
According to MDN, the first parameter contains entire substring, not the first capture group. As the result, the
childPID
contains string, not just number (“pid: 1234”).nodemon/test/fixtures/sigint.js
Lines 1 to 3 in cd45d74
In fact, you can see it in the process list after running tests even if all tests pass.
nodemon/test/misc/sigint.test.js
Lines 37 to 42 in cd45d74
This happens because
childPID
is string andprocess.kill
requires number and throws an exception. Due to exception, the test code assumes the child is not running and test passes.Tested on:
master
)The fix
I implemented the following fixes:
--dont-exit
parameter is passed. In all other cases it exits upon receiving SIGINT as any normal application would do.