Skip to content

Commit

Permalink
test: log more information in debugger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Aug 23, 2022
1 parent 6566307 commit 1140002
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/internal/debugger/inspect_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,17 @@ class Client extends EventEmitter {
if (payloadBuffer === null || payloadBuffer.length === 0) break;

const payloadStr = payloadBuffer.toString();
debuglog('< %s', payloadStr);
if (payloadStr.startsWith('{"method":"Debugger.scriptParsed"')) {
// Do not log Debugger.scriptParsed events because the payloads
// can be huge.
debuglog('< Debugger.scriptParsed ...');
} else if (payloadStr.startsWith('{"method":"Debugger.paused"')) {
// Do not log Debugger.paused events because the payloads
// can be huge.
debuglog('< Debugger.paused ...');
} else {
debuglog('< %s', payloadStr);
}
const lastChar = payloadStr[payloadStr.length - 1];
if (payloadStr[0] !== '{' || lastChar !== '}') {
throw new ERR_DEBUGGER_ERROR(`Payload does not look like JSON: ${payloadStr}`);
Expand Down
5 changes: 4 additions & 1 deletion test/common/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ const BREAK_MESSAGE = new RegExp('(?:' + [
'exception', 'other', 'promiseRejection',
].join('|') + ') in', 'i');

const TIMEOUT = common.platformTimeout(5000);
let TIMEOUT = common.platformTimeout(5000);
if (common.isWindows) {
TIMEOUT = common.platformTimeout(15000);
}

function isPreBreak(output) {
return /Break on start/.test(output) && /1 \(function \(exports/.test(output);
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-debugger-breakpoint-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');

process.env.NODE_DEBUG = 'inspect';
// Test for "Breakpoint at specified location already exists" error.
{
const script = fixtures.path('debugger', 'three-lines.js');
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-debugger-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');

const assert = require('assert');
process.env.NODE_DEBUG = 'inspect';

{
const cli = startCLI([fixtures.path('debugger/empty.js')]);
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-debugger-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const startCLI = require('../common/debugger');

const assert = require('assert');

process.env.NODE_DEBUG = 'inspect';
const cli = startCLI([fixtures.path('debugger/three-lines.js')]);

(async () => {
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-debugger-low-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');
const assert = require('assert');
process.env.NODE_DEBUG = 'inspect';

// Debugger agent direct access.
{
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-debugger-random-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const startCLI = require('../common/debugger');

const assert = require('assert');

process.env.NODE_DEBUG = 'inspect';
// Random port.
{
const script = fixtures.path('debugger', 'three-lines.js');
Expand Down

0 comments on commit 1140002

Please sign in to comment.