test: fix test-watch-mode-inspect
Refs: https://github.com/nodejs/node/issues/44898 PR-URL: https://github.com/nodejs/node/pull/45586 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Erick Wendel <erick.workspace@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
c89f9d3fd4
commit
2cad517854
@ -12,26 +12,34 @@ if (common.isIBMi)
|
|||||||
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
|
|
||||||
|
let gettingDebuggedPid = false;
|
||||||
|
|
||||||
|
async function getDebuggedPid(instance, waitForLog = true) {
|
||||||
|
gettingDebuggedPid = true;
|
||||||
|
const session = await instance.connectInspectorSession();
|
||||||
|
await session.send({ method: 'Runtime.enable' });
|
||||||
|
if (waitForLog) {
|
||||||
|
await session.waitForConsoleOutput('log', 'safe to debug now');
|
||||||
|
}
|
||||||
|
const { value: innerPid } = (await session.send({
|
||||||
|
'method': 'Runtime.evaluate', 'params': { 'expression': 'process.pid' }
|
||||||
|
})).result;
|
||||||
|
session.disconnect();
|
||||||
|
gettingDebuggedPid = false;
|
||||||
|
return innerPid;
|
||||||
|
}
|
||||||
|
|
||||||
function restart(file) {
|
function restart(file) {
|
||||||
writeFileSync(file, readFileSync(file));
|
writeFileSync(file, readFileSync(file));
|
||||||
const interval = setInterval(() => writeFileSync(file, readFileSync(file)), 500);
|
const interval = setInterval(() => {
|
||||||
|
if (!gettingDebuggedPid) {
|
||||||
|
writeFileSync(file, readFileSync(file));
|
||||||
|
}
|
||||||
|
}, common.platformTimeout(500));
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('watch mode - inspect', () => {
|
describe('watch mode - inspect', () => {
|
||||||
async function getDebuggedPid(instance, waitForLog = true) {
|
|
||||||
const session = await instance.connectInspectorSession();
|
|
||||||
await session.send({ method: 'Runtime.enable' });
|
|
||||||
if (waitForLog) {
|
|
||||||
await session.waitForConsoleOutput('log', 'safe to debug now');
|
|
||||||
}
|
|
||||||
const { value: innerPid } = (await session.send({
|
|
||||||
'method': 'Runtime.evaluate', 'params': { 'expression': 'process.pid' }
|
|
||||||
})).result;
|
|
||||||
session.disconnect();
|
|
||||||
return innerPid;
|
|
||||||
}
|
|
||||||
|
|
||||||
it('should start debugger on inner process', async () => {
|
it('should start debugger on inner process', async () => {
|
||||||
const file = fixtures.path('watch-mode/inspect.js');
|
const file = fixtures.path('watch-mode/inspect.js');
|
||||||
const instance = new NodeInstance(['--inspect=0', '--watch'], undefined, file);
|
const instance = new NodeInstance(['--inspect=0', '--watch'], undefined, file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user