Skip to content

Commit 65fa95d

Browse files
ulitinkmarco-ippolito
authored andcommitted
test: add Debugger.setInstrumentationBreakpoint known issue
PR-URL: #31137 Refs: #31138 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0c5e589 commit 65fa95d

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

test/common/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ function printSkipMessage(msg) {
598598

599599
function skip(msg) {
600600
printSkipMessage(msg);
601-
process.exit(0);
601+
// In known_issues test, skipping should produce a non-zero exit code.
602+
process.exit(require.main?.filename.startsWith(path.resolve(__dirname, '../known_issues/')) ? 1 : 0);
602603
}
603604

604605
// Returns true if the exit code "exitCode" and/or signal name "signal"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('dep loaded');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./dep');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// This test validates inspector's Debugger.setInstrumentationBreakpoint method.
2+
// Refs: https://github.com/nodejs/node/issues/31138
3+
4+
'use strict';
5+
const common = require('../common');
6+
7+
common.skipIfInspectorDisabled();
8+
9+
const assert = require('assert');
10+
const { resolve: UrlResolve } = require('url');
11+
const fixtures = require('../common/fixtures');
12+
const { NodeInstance } = require('../common/inspector-helper.js');
13+
14+
async function testBreakpointBeforeScriptExecution(session) {
15+
console.log('[test]',
16+
'Verifying debugger stops on start of each script ' +
17+
'(Debugger.setInstrumentationBreakpoint with beforeScriptExecution)');
18+
const commands = [
19+
{ 'method': 'Runtime.enable' },
20+
{ 'method': 'Debugger.enable' },
21+
{ 'method': 'Debugger.setInstrumentationBreakpoint',
22+
'params': { 'instrumentation': 'beforeScriptExecution' } },
23+
{ 'method': 'Runtime.runIfWaitingForDebugger' },
24+
];
25+
26+
await session.send(commands);
27+
28+
// Break on start
29+
await session.waitForBreakOnLine(
30+
0, UrlResolve(session.scriptURL().toString(), 'main.js'));
31+
await session.send([{ 'method': 'Debugger.resume' }]);
32+
33+
// Script loaded
34+
await session.waitForBreakOnLine(
35+
0, UrlResolve(session.scriptURL().toString(), 'main.js'));
36+
await session.send([{ 'method': 'Debugger.resume' }]);
37+
38+
// Script loaded
39+
await session.waitForBreakOnLine(
40+
0, UrlResolve(session.scriptURL().toString(), 'dep.js'));
41+
await session.send([{ 'method': 'Debugger.resume' }]);
42+
}
43+
44+
async function runTest() {
45+
const main = fixtures.path('inspector-instrumentation-breakpoint', 'main.js');
46+
const child = new NodeInstance(['--inspect-brk=0'], '', main);
47+
48+
const session = await child.connectInspectorSession();
49+
await testBreakpointBeforeScriptExecution(session);
50+
await session.runToCompletion();
51+
assert.strictEqual((await child.expectShutdown()).exitCode, 0);
52+
}
53+
54+
runTest();

0 commit comments

Comments
 (0)