Skip to content

Commit

Permalink
test: fix test-watch-mode-inspect
Browse files Browse the repository at this point in the history
Refs: #44898
PR-URL: #45586
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
StefanStojanovic authored and danielleadams committed Jan 3, 2023
1 parent 1ff8f68 commit 3a5a2ae
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 3a5a2ae

Please sign in to comment.