node-qunit
node-qunit copied to clipboard
Add test debugging support
When cli.js executed by Node.js running in debug mode, child processes are also running in debug mode with different port. It is possible to run cli.js in normal mode and debug only child processes using --debug option. It is possible to specify debug port after --debug option.
Close #108.
I should rewrite the cli with commander ...
Hmm ... if we need to debug just one child why do we need all this. Arguments are passed to the child in any case.
The only thing we need is to avoid that runner process gets this flag.
Hmm ... if we need to debug just one child why do we need all this. Arguments are passed to the child in any case.
The problem is not in passing debug argument to child process, but deeper - in fixing node way of spawning new processes when parent process is running in debug mode; also in ability to run child process in debug mode when parent process is running in normal mode.
There are two parts that should be handled:
testrunner.jsshould change execution arguments passed to node (execArgvnotargv) in order to start child process on different debugging port. Therefore passing arguments to child process is not enough, parentprocessshould be reconfigured each time before spawning new child process.child.jsshould be notified that it is running in debug mode in order to stop sendingpingmessages, otherwise process will be killed aftermaxBlockDurationwith message "Error: Process blocked for too long".debugoption is passed to it in order to avoid duplication of logic that recognises that process is running in debug mode. It may be handy, since there are at least 3 scenarios that cause child process to run in debug mode.
It is possible to simplify logic, avoid --debug flag at all (on cost of flexibility), move logic to recognise debug mode from cli.js to testrunner.js only, not pass debug option to child.js and simply not run block that setups pingCheckTimeoutId in debug mode (which will cause child process to continue polluting event queue with irrelevant ping messages form time to time). In this case everything relevant to debug mode will be handled in testrunner.js. If you think it's the better way, I can make another PR, just let me know. And thanks again for your time :)
Guys, what is required to merge this PR? Or do you have any other suggestions on how to debug qunit tests?