Files
node/test/parallel/test-debugger-probe-max-hit-invalid.js
T
Joyee Cheung 8c4ec8a674 debugger: add --max-hit option to probe mode
This option provides a new way of terminating the probing by
specifying a limit for the per-probe hit evaluation. When any
probe reaches the limit, the session removes the V8 breakpoints
and finishes with a `completed` terminal event rather than waiting
for the target to exit or timeout. This would be useful when we
provide a way to attach to and probe a running process in the future.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63704
Refs: https://github.com/nodejs/node/issues/63646
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-06-13 20:50:15 +00:00

41 lines
1.5 KiB
JavaScript

// This tests that probe mode rejects malformed --max-hit usage.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const { assertProbeCliError } = require('../common/debugger-probe');
const cwd = fixtures.path('debugger');
// --max-hit before any --probe.
assertProbeCliError(
['--max-hit', '1', '--probe', 'probe.js:12', '--expr', 'finalValue', 'probe.js'],
/Unexpected --max-hit before --probe/, { cwd });
// --max-hit between a --probe and its --expr.
assertProbeCliError(
['--probe', 'probe.js:12', '--max-hit', '1', '--expr', 'finalValue', 'probe.js'],
/Each --probe must be followed immediately by --expr/, { cwd });
// Duplicate --max-hit for a single probe.
assertProbeCliError(
['--probe', 'probe.js:12', '--expr', 'finalValue', '--max-hit', '1', '--max-hit', '2', 'probe.js'],
/Duplicate --max-hit for a single --probe/, { cwd });
// Non-numeric value.
assertProbeCliError(
['--probe', 'probe.js:12', '--expr', 'finalValue', '--max-hit', 'abc', 'probe.js'],
/Invalid max-hit: abc/, { cwd });
// Zero is not allowed (limit must be at least 1).
assertProbeCliError(
['--probe', 'probe.js:12', '--expr', 'finalValue', '--max-hit', '0', 'probe.js'],
/Invalid max-hit: 0/, { cwd });
// Missing value: --max-hit as the final token has nothing to consume.
assertProbeCliError(
['--probe', 'probe.js:12', '--expr', 'finalValue', '--max-hit'],
/Missing value for --max-hit/, { cwd });