Skip to content

Commit

Permalink
test: fix test-watch-mode-inspect
Browse files Browse the repository at this point in the history
Refs: #44898
  • Loading branch information
StefanStojanovic committed Nov 22, 2022
1 parent b4c2004 commit b8a699e
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions test/sequential/test-watch-mode-inspect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,34 @@ if (common.isIBMi)

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) {
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);
}

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 () => {
const file = fixtures.path('watch-mode/inspect.js');
const instance = new NodeInstance(['--inspect=0', '--watch'], undefined, file);
Expand Down

0 comments on commit b8a699e

Please sign in to comment.