Skip to content

Commit b0c9545

Browse files
committed
fixup! test: normalize known inspector crash as completion
1 parent 678ee5b commit b0c9545

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

test/common/debugger-probe.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,43 @@ const assert = require('assert');
44
const fixtures = require('./fixtures');
55
const path = require('path');
66

7-
const probeTargetExitSignal = 'SIGSEGV';
8-
const probeTargetExitMessage =
9-
`Target exited with signal ${probeTargetExitSignal} before target completion`;
10-
117
function debuggerFixturePath(name) {
128
return path.relative(process.cwd(), fixtures.path('debugger', name));
139
}
1410

1511
// Work around a pre-existing inspector issue: if the debuggee exits too quickly
16-
// the inspector can segfault while tearing down. For now normalize the
17-
// trailing segfault as completion until the upstream bug is fixed.
12+
// the inspector can segfault while tearing down. For now normalize the segfault
13+
// back to the expected terminal event (e.g. "completed" or "miss")
14+
// until the upstream bug is fixed.
1815
// See https://github.com/nodejs/node/issues/62765
1916
// https://github.com/nodejs/node/issues/58245
17+
const probeTargetExitSignal = 'SIGSEGV';
18+
2019
function assertProbeJson(output, expected) {
2120
const normalized = JSON.parse(output);
2221
const lastResult = normalized.results?.[normalized.results.length - 1];
2322

2423
if (lastResult?.event === 'error' &&
2524
lastResult.error?.code === 'probe_target_exit' &&
26-
lastResult.error?.signal === probeTargetExitSignal &&
27-
lastResult.error?.message === probeTargetExitMessage) {
25+
lastResult.error?.signal === probeTargetExitSignal) {
2826
// Log to facilitate debugging if this normalization is occurring.
2927
console.log('Normalizing trailing SIGSEGV in JSON probe output');
30-
normalized.results[normalized.results.length - 1] = { event: 'completed' };
28+
normalized.results[normalized.results.length - 1] =
29+
expected.results[expected.results.length - 1];
3130
}
3231

3332
assert.deepStrictEqual(normalized, expected);
3433
}
3534

3635
function assertProbeText(output, expected) {
37-
const idx = output.indexOf(probeTargetExitMessage);
36+
const signalPrefix = `Target exited with signal ${probeTargetExitSignal}`;
37+
const idx = output.indexOf(signalPrefix);
3838
let normalized;
3939
if (idx !== -1) {
4040
// Log to facilitate debugging if this normalization is occurring.
4141
console.log('Normalizing trailing SIGSEGV in text probe output');
42-
normalized = output.slice(0, output.lastIndexOf('\n', idx)) + '\nCompleted';
42+
const lineStart = output.lastIndexOf('\n', idx);
43+
normalized = (lineStart === -1 ? '' : output.slice(0, lineStart)) + '\nCompleted';
4344
} else {
4445
normalized = output;
4546
}

0 commit comments

Comments
 (0)