Skip to content
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: fix test-watch-mode-inspect #45586

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 22 additions & 14 deletions test/sequential/test-watch-mode-inspect.mjs
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) {
MoLow marked this conversation as resolved.
Show resolved Hide resolved
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