mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
test: normalize known inspector crash as completion
This works around a pre-existing inspector issue: if the debuggee exits too quickly the inspector can segfault while tearing down. For now normalize the trailing segfault as completion to keep the CI green until the upstream bug is fixed, since it only reproduces on some slow CI machines and is not what the probe tests care about. PR-URL: https://github.com/nodejs/node/pull/62851 Refs: https://github.com/nodejs/node/issues/62765 Refs: https://github.com/nodejs/node/issues/58245 Reviewed-By: Jan Martin <jan.krems@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 parent
1f6f3ac871
commit
3dc06aef21
10 files changed
+69
-33
No files matched your search
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const fixtures = require('./fixtures');
|
||||
const path = require('path');
|
||||
|
||||
@@ -7,12 +8,47 @@ function debuggerFixturePath(name) {
|
||||
return path.relative(process.cwd(), fixtures.path('debugger', name));
|
||||
}
|
||||
|
||||
function escapeRegex(string) {
|
||||
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
// Work around a pre-existing inspector issue: if the debuggee exits too quickly
|
||||
// the inspector can segfault while tearing down. For now normalize the segfault
|
||||
// back to the expected terminal event (e.g. "completed" or "miss")
|
||||
// until the upstream bug is fixed.
|
||||
// See https://github.com/nodejs/node/issues/62765
|
||||
// https://github.com/nodejs/node/issues/58245
|
||||
const probeTargetExitSignal = 'SIGSEGV';
|
||||
|
||||
function assertProbeJson(output, expected) {
|
||||
const normalized = JSON.parse(output);
|
||||
const lastResult = normalized.results?.[normalized.results.length - 1];
|
||||
|
||||
if (lastResult?.event === 'error' &&
|
||||
lastResult.error?.code === 'probe_target_exit' &&
|
||||
lastResult.error?.signal === probeTargetExitSignal) {
|
||||
// Log to facilitate debugging if this normalization is occurring.
|
||||
console.log('Normalizing trailing SIGSEGV in JSON probe output');
|
||||
normalized.results[normalized.results.length - 1] = expected.results.at(-1);
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(normalized, expected);
|
||||
}
|
||||
|
||||
function assertProbeText(output, expected) {
|
||||
const signalPrefix = `Target exited with signal ${probeTargetExitSignal}`;
|
||||
const idx = output.indexOf(signalPrefix);
|
||||
let normalized;
|
||||
if (idx !== -1) {
|
||||
// Log to facilitate debugging if this normalization is occurring.
|
||||
console.log('Normalizing trailing SIGSEGV in text probe output');
|
||||
const lineStart = output.lastIndexOf('\n', idx);
|
||||
normalized = (lineStart === -1 ? '' : output.slice(0, lineStart)) + '\nCompleted';
|
||||
} else {
|
||||
normalized = output;
|
||||
}
|
||||
assert.strictEqual(normalized, expected);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
escapeRegex,
|
||||
assertProbeJson,
|
||||
assertProbeText,
|
||||
missScript: debuggerFixturePath('probe-miss.js'),
|
||||
probeScript: debuggerFixturePath('probe.js'),
|
||||
throwScript: debuggerFixturePath('probe-throw.js'),
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeScript } = require('../common/debugger-probe');
|
||||
const { assertProbeJson, probeScript } = require('../common/debugger-probe');
|
||||
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
'inspect',
|
||||
@@ -18,7 +17,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [{
|
||||
expr: 'finalValue',
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeScript } = require('../common/debugger-probe');
|
||||
const { assertProbeJson, probeScript } = require('../common/debugger-probe');
|
||||
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
'inspect',
|
||||
@@ -16,7 +15,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [{
|
||||
expr: 'finalValue',
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeTypesScript } = require('../common/debugger-probe');
|
||||
const {
|
||||
assertProbeJson,
|
||||
probeTypesScript,
|
||||
} = require('../common/debugger-probe');
|
||||
|
||||
const location = `${probeTypesScript}:17`;
|
||||
|
||||
@@ -23,7 +25,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeTypesScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [
|
||||
{ expr: 'objectValue', target: [probeTypesScript, 17] },
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeTypesScript } = require('../common/debugger-probe');
|
||||
const {
|
||||
assertProbeJson,
|
||||
probeTypesScript,
|
||||
} = require('../common/debugger-probe');
|
||||
|
||||
const location = `${probeTypesScript}:17`;
|
||||
|
||||
@@ -38,7 +40,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeTypesScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [
|
||||
{ expr: 'stringValue', target: [probeTypesScript, 17] },
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeScript } = require('../common/debugger-probe');
|
||||
const { assertProbeJson, probeScript } = require('../common/debugger-probe');
|
||||
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
'inspect',
|
||||
@@ -20,7 +19,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [
|
||||
{ expr: 'index', target: [probeScript, 8] },
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { missScript } = require('../common/debugger-probe');
|
||||
const { assertProbeJson, missScript } = require('../common/debugger-probe');
|
||||
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
'inspect',
|
||||
@@ -16,7 +15,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
missScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [{ expr: '42', target: [missScript, 99] }],
|
||||
results: [{
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeTypesScript } = require('../common/debugger-probe');
|
||||
const {
|
||||
assertProbeText,
|
||||
probeTypesScript,
|
||||
} = require('../common/debugger-probe');
|
||||
|
||||
const location = `${probeTypesScript}:17`;
|
||||
|
||||
@@ -37,7 +39,7 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeTypesScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.strictEqual(output, [
|
||||
assertProbeText(output, [
|
||||
`Hit 1 at ${location}`,
|
||||
' stringValue = "hello"',
|
||||
`Hit 1 at ${location}`,
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { probeScript } = require('../common/debugger-probe');
|
||||
const { assertProbeText, probeScript } = require('../common/debugger-probe');
|
||||
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
'inspect',
|
||||
@@ -15,10 +14,10 @@ spawnSyncAndAssert(process.execPath, [
|
||||
probeScript,
|
||||
], {
|
||||
stdout(output) {
|
||||
assert.strictEqual(output,
|
||||
`Hit 1 at ${probeScript}:12\n` +
|
||||
' finalValue = 81\n' +
|
||||
'Completed');
|
||||
assertProbeText(output,
|
||||
`Hit 1 at ${probeScript}:12\n` +
|
||||
' finalValue = 81\n' +
|
||||
'Completed');
|
||||
},
|
||||
trim: true,
|
||||
});
|
||||
@@ -4,9 +4,8 @@
|
||||
const common = require('../common');
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { spawnSyncAndExit } = require('../common/child_process');
|
||||
const { timeoutScript } = require('../common/debugger-probe');
|
||||
const { assertProbeJson, timeoutScript } = require('../common/debugger-probe');
|
||||
|
||||
spawnSyncAndExit(process.execPath, [
|
||||
'inspect',
|
||||
@@ -19,7 +18,7 @@ spawnSyncAndExit(process.execPath, [
|
||||
signal: null,
|
||||
status: 1,
|
||||
stdout(output) {
|
||||
assert.deepStrictEqual(JSON.parse(output), {
|
||||
assertProbeJson(output, {
|
||||
v: 1,
|
||||
probes: [{ expr: '1', target: [timeoutScript, 99] }],
|
||||
results: [{
|
||||
|
||||
Reference in new issue
Block a user