-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: test clusters --inspect-brk and --debug-brk #11471
Changes from 1 commit
63e78ed
e2c86af
c6c73d2
e7b1975
ab85649
e1ccdcb
c39b078
9f9a725
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
// This test ensures that flag --inspect-brk and --debug-brk works properly | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cluster = require('cluster'); | ||
|
||
const script = common.fixturesDir + '/empty.js'; | ||
|
||
function fail() { | ||
assert(0); // `node --debug-brk script.js` should not quit | ||
} | ||
|
||
if (cluster.isMaster) { | ||
|
||
function fork(execArgv) { | ||
cluster.setupMaster({execArgv}); | ||
let worker = cluster.fork(); | ||
|
||
worker.on('exit', fail); | ||
|
||
// give node time to start up the debugger | ||
setTimeout(() => { | ||
worker.removeListener('exit', fail); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of having this |
||
worker.kill(); | ||
}, 2000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like a recipe for a flaky test, I'd suggest waiting until the debug/inspect TCP port is open/can be connected to |
||
|
||
return worker; | ||
} | ||
|
||
let workers = [ | ||
fork([script, '--inspect-brk']), | ||
fork([script, `--inspect-brk=5959`]), | ||
fork([script, '--debug-brk']), | ||
fork([script, `--debug-brk=9230`]) | ||
]; | ||
|
||
process.on('exit', function() { | ||
workers.map((wk) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want |
||
assert.equal(wk.process.killed, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, please use
common.fail()
orcommon.mustNotCall()
, which are designed to do essentially this same thing without cluttering up the tests.