From 5286379020efd9ca3ab418779cd71418c6733f2d Mon Sep 17 00:00:00 2001 From: Konstantin Ulitin Date: Mon, 30 Dec 2019 13:47:24 +0100 Subject: [PATCH 1/6] test: add `Debugger.setInstrumentationBreakpoint` known issue --- .../dep.js | 1 + .../main.js | 1 + ...st-inspector-instrumentation-breakpoint.js | 51 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 test/fixtures/inspector-instrumentation-breakpoint/dep.js create mode 100644 test/fixtures/inspector-instrumentation-breakpoint/main.js create mode 100644 test/parallel/test-inspector-instrumentation-breakpoint.js diff --git a/test/fixtures/inspector-instrumentation-breakpoint/dep.js b/test/fixtures/inspector-instrumentation-breakpoint/dep.js new file mode 100644 index 00000000000000..ebc9d24306de57 --- /dev/null +++ b/test/fixtures/inspector-instrumentation-breakpoint/dep.js @@ -0,0 +1 @@ +console.log("dep loaded"); diff --git a/test/fixtures/inspector-instrumentation-breakpoint/main.js b/test/fixtures/inspector-instrumentation-breakpoint/main.js new file mode 100644 index 00000000000000..ff740fc52495ca --- /dev/null +++ b/test/fixtures/inspector-instrumentation-breakpoint/main.js @@ -0,0 +1 @@ +require("./dep"); \ No newline at end of file diff --git a/test/parallel/test-inspector-instrumentation-breakpoint.js b/test/parallel/test-inspector-instrumentation-breakpoint.js new file mode 100644 index 00000000000000..2cee7dbfa7ef13 --- /dev/null +++ b/test/parallel/test-inspector-instrumentation-breakpoint.js @@ -0,0 +1,51 @@ +'use strict'; +const common = require('../common'); + +common.skipIfInspectorDisabled(); + +const assert = require('assert'); +const { resolve: UrlResolve } = require('url'); +const fixtures = require('../common/fixtures'); +const { NodeInstance } = require('../common/inspector-helper.js'); + +async function testBreakpointBeforeScriptExecution(session) { + console.log('[test]', + 'Verifying debugger stops on start of each script ' + + '(Debugger.setInstrumentationBreakpoint with beforeScriptExecution)'); + const commands = [ + { 'method': 'Runtime.enable' }, + { 'method': 'Debugger.enable' }, + { 'method': 'Debugger.setInstrumentationBreakpoint', + 'params': { 'instrumentation': 'beforeScriptExecution' } }, + { 'method': 'Runtime.runIfWaitingForDebugger' } + ]; + + await session.send(commands); + + // Break on start + await session.waitForBreakOnLine( + 0, UrlResolve(session.scriptURL().toString(), 'main.js')); + await session.send([{'method': 'Debugger.resume'}]); + + // Script loaded + await session.waitForBreakOnLine( + 0, UrlResolve(session.scriptURL().toString(), 'main.js')); + await session.send([{'method': 'Debugger.resume'}]); + + // Script loaded + await session.waitForBreakOnLine( + 0, UrlResolve(session.scriptURL().toString(), 'dep.js')); + await session.send([{'method': 'Debugger.resume'}]); +} + +async function runTest() { + const child = new NodeInstance(['--inspect-brk=0'], '', + fixtures.path('inspector-instrumentation-breakpoint', 'main.js')); + + const session = await child.connectInspectorSession(); + await testBreakpointBeforeScriptExecution(session); + await session.runToCompletion(); + assert.strictEqual((await child.expectShutdown()).exitCode, 0); +} + +runTest(); From 6a74aa6b41209de857486af2f3c162f361599a01 Mon Sep 17 00:00:00 2001 From: Konstantin Ulitin Date: Wed, 8 Jan 2020 18:51:29 +0100 Subject: [PATCH 2/6] test: mute test-inspector-instrumentation-breakpoint --- .../test-inspector-instrumentation-breakpoint.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{parallel => known_issues}/test-inspector-instrumentation-breakpoint.js (100%) diff --git a/test/parallel/test-inspector-instrumentation-breakpoint.js b/test/known_issues/test-inspector-instrumentation-breakpoint.js similarity index 100% rename from test/parallel/test-inspector-instrumentation-breakpoint.js rename to test/known_issues/test-inspector-instrumentation-breakpoint.js From 38aa857c9c9075d74b11857844f0cf5dfd39c7c2 Mon Sep 17 00:00:00 2001 From: Konstantin Ulitin Date: Fri, 10 Jan 2020 19:09:55 +0100 Subject: [PATCH 3/6] test: fix formatting in test-inspector-instrumentation-breakpoint --- .../test-inspector-instrumentation-breakpoint.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/known_issues/test-inspector-instrumentation-breakpoint.js b/test/known_issues/test-inspector-instrumentation-breakpoint.js index 2cee7dbfa7ef13..a975c2fa28e6ac 100644 --- a/test/known_issues/test-inspector-instrumentation-breakpoint.js +++ b/test/known_issues/test-inspector-instrumentation-breakpoint.js @@ -25,22 +25,22 @@ async function testBreakpointBeforeScriptExecution(session) { // Break on start await session.waitForBreakOnLine( 0, UrlResolve(session.scriptURL().toString(), 'main.js')); - await session.send([{'method': 'Debugger.resume'}]); + await session.send([{ 'method': 'Debugger.resume' }]); // Script loaded await session.waitForBreakOnLine( 0, UrlResolve(session.scriptURL().toString(), 'main.js')); - await session.send([{'method': 'Debugger.resume'}]); + await session.send([{ 'method': 'Debugger.resume' }]); // Script loaded await session.waitForBreakOnLine( 0, UrlResolve(session.scriptURL().toString(), 'dep.js')); - await session.send([{'method': 'Debugger.resume'}]); + await session.send([{ 'method': 'Debugger.resume' }]); } async function runTest() { - const child = new NodeInstance(['--inspect-brk=0'], '', - fixtures.path('inspector-instrumentation-breakpoint', 'main.js')); + const main = fixtures.path('inspector-instrumentation-breakpoint', 'main.js'); + const child = new NodeInstance(['--inspect-brk=0'], '', main); const session = await child.connectInspectorSession(); await testBreakpointBeforeScriptExecution(session); From 833be9c83e86a96024635640c20e788729c97f96 Mon Sep 17 00:00:00 2001 From: Konstantin Ulitin Date: Tue, 18 Feb 2020 19:53:18 +0100 Subject: [PATCH 4/6] test: add description, fix linters --- test/fixtures/inspector-instrumentation-breakpoint/dep.js | 2 +- test/fixtures/inspector-instrumentation-breakpoint/main.js | 2 +- test/known_issues/test-inspector-instrumentation-breakpoint.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/fixtures/inspector-instrumentation-breakpoint/dep.js b/test/fixtures/inspector-instrumentation-breakpoint/dep.js index ebc9d24306de57..e2ba44676df631 100644 --- a/test/fixtures/inspector-instrumentation-breakpoint/dep.js +++ b/test/fixtures/inspector-instrumentation-breakpoint/dep.js @@ -1 +1 @@ -console.log("dep loaded"); +console.log('dep loaded'); diff --git a/test/fixtures/inspector-instrumentation-breakpoint/main.js b/test/fixtures/inspector-instrumentation-breakpoint/main.js index ff740fc52495ca..a0b8fdf1c94ad4 100644 --- a/test/fixtures/inspector-instrumentation-breakpoint/main.js +++ b/test/fixtures/inspector-instrumentation-breakpoint/main.js @@ -1 +1 @@ -require("./dep"); \ No newline at end of file +require('./dep'); diff --git a/test/known_issues/test-inspector-instrumentation-breakpoint.js b/test/known_issues/test-inspector-instrumentation-breakpoint.js index a975c2fa28e6ac..916b05b77212d1 100644 --- a/test/known_issues/test-inspector-instrumentation-breakpoint.js +++ b/test/known_issues/test-inspector-instrumentation-breakpoint.js @@ -1,3 +1,6 @@ +// This test validates inspector's Debugger.setInstrumentationBreakpoint method. +// Refs: https://github.com/nodejs/node/issues/31138 + 'use strict'; const common = require('../common'); From 9c8a4527795728f136961d71e79abaeda1a9e432 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 23 Oct 2023 19:55:25 +0200 Subject: [PATCH 5/6] lint --- test/known_issues/test-inspector-instrumentation-breakpoint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/known_issues/test-inspector-instrumentation-breakpoint.js b/test/known_issues/test-inspector-instrumentation-breakpoint.js index 916b05b77212d1..0105097f2baf4a 100644 --- a/test/known_issues/test-inspector-instrumentation-breakpoint.js +++ b/test/known_issues/test-inspector-instrumentation-breakpoint.js @@ -20,7 +20,7 @@ async function testBreakpointBeforeScriptExecution(session) { { 'method': 'Debugger.enable' }, { 'method': 'Debugger.setInstrumentationBreakpoint', 'params': { 'instrumentation': 'beforeScriptExecution' } }, - { 'method': 'Runtime.runIfWaitingForDebugger' } + { 'method': 'Runtime.runIfWaitingForDebugger' }, ]; await session.send(commands); From 29607a1e5f48ec6e0c2520dfd650f0942da4ff55 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 11 May 2024 10:42:17 +0200 Subject: [PATCH 6/6] better skip --- test/common/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index 84805723e4be6a..4fbaf91fea1ef9 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -603,7 +603,8 @@ function printSkipMessage(msg) { function skip(msg) { printSkipMessage(msg); - process.exit(0); + // In known_issues test, skipping should produce a non-zero exit code. + process.exit(require.main?.filename.startsWith(path.resolve(__dirname, '../known_issues/')) ? 1 : 0); } // Returns true if the exit code "exitCode" and/or signal name "signal"