node-qunit icon indicating copy to clipboard operation
node-qunit copied to clipboard

Add test debugging support

Open micellius opened this issue 11 years ago • 5 comments

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.

micellius avatar Nov 04 '14 22:11 micellius

I should rewrite the cli with commander ...

kof avatar Nov 08 '14 11:11 kof

Hmm ... if we need to debug just one child why do we need all this. Arguments are passed to the child in any case.

kof avatar Nov 08 '14 14:11 kof

The only thing we need is to avoid that runner process gets this flag.

kof avatar Nov 08 '14 14:11 kof

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.js should change execution arguments passed to node (execArgv not argv) in order to start child process on different debugging port. Therefore passing arguments to child process is not enough, parent process should be reconfigured each time before spawning new child process.
  • child.js should be notified that it is running in debug mode in order to stop sending ping messages, otherwise process will be killed after maxBlockDuration with message "Error: Process blocked for too long". debug option 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 :)

micellius avatar Nov 08 '14 18:11 micellius

Guys, what is required to merge this PR? Or do you have any other suggestions on how to debug qunit tests?

SPopenko avatar Aug 06 '18 10:08 SPopenko