GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: normalize known inspector crash as completion · nodejs/node@da4dd86

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • common
      • debugger-probe.js
    • parallel
      • test-debugger-probe-child-inspect-port-zero.js
      • test-debugger-probe-global-option-order.js
      • test-debugger-probe-json-preview.js
      • test-debugger-probe-json-special-values.js
      • test-debugger-probe-json.js
      • test-debugger-probe-miss.js
      • test-debugger-probe-text-special-values.js
      • test-debugger-probe-text.js
      • test-debugger-probe-timeout.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/common/debugger-probe.js‎

Copy file name to clipboardExpand all lines: test/common/debugger-probe.js
+39-3Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,54 @@
11
'use strict';
22

3+
const assert = require('assert');
34
const fixtures = require('./fixtures');
45
const path = require('path');
56

67
function debuggerFixturePath(name) {
78
return path.relative(process.cwd(), fixtures.path('debugger', name));
89
}
910

10-
function escapeRegex(string) {
11-
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
11+
// Work around a pre-existing inspector issue: if the debuggee exits too quickly
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.
15+
// See https://github.com/nodejs/node/issues/62765
16+
// https://github.com/nodejs/node/issues/58245
17+
const probeTargetExitSignal = 'SIGSEGV';
18+
19+
function assertProbeJson(output, expected) {
20+
const normalized = JSON.parse(output);
21+
const lastResult = normalized.results?.[normalized.results.length - 1];
22+
23+
if (lastResult?.event === 'error' &&
24+
lastResult.error?.code === 'probe_target_exit' &&
25+
lastResult.error?.signal === probeTargetExitSignal) {
26+
// Log to facilitate debugging if this normalization is occurring.
27+
console.log('Normalizing trailing SIGSEGV in JSON probe output');
28+
normalized.results[normalized.results.length - 1] = expected.results.at(-1);
29+
}
30+
31+
assert.deepStrictEqual(normalized, expected);
32+
}
33+
34+
function assertProbeText(output, expected) {
35+
const signalPrefix = `Target exited with signal ${probeTargetExitSignal}`;
36+
const idx = output.indexOf(signalPrefix);
37+
let normalized;
38+
if (idx !== -1) {
39+
// Log to facilitate debugging if this normalization is occurring.
40+
console.log('Normalizing trailing SIGSEGV in text probe output');
41+
const lineStart = output.lastIndexOf('\n', idx);
42+
normalized = (lineStart === -1 ? '' : output.slice(0, lineStart)) + '\nCompleted';
43+
} else {
44+
normalized = output;
45+
}
46+
assert.strictEqual(normalized, expected);
1247
}
1348

1449
module.exports = {
15-
escapeRegex,
50+
assertProbeJson,
51+
assertProbeText,
1652
missScript: debuggerFixturePath('probe-miss.js'),
1753
probeScript: debuggerFixturePath('probe.js'),
1854
throwScript: debuggerFixturePath('probe-throw.js'),
Collapse file

‎test/parallel/test-debugger-probe-child-inspect-port-zero.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-child-inspect-port-zero.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeScript } = require('../common/debugger-probe');
8+
const { assertProbeJson, probeScript } = require('../common/debugger-probe');
109

1110
spawnSyncAndAssert(process.execPath, [
1211
'inspect',
@@ -18,7 +17,7 @@ spawnSyncAndAssert(process.execPath, [
1817
probeScript,
1918
], {
2019
stdout(output) {
21-
assert.deepStrictEqual(JSON.parse(output), {
20+
assertProbeJson(output, {
2221
v: 1,
2322
probes: [{
2423
expr: 'finalValue',
Collapse file

‎test/parallel/test-debugger-probe-global-option-order.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-global-option-order.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeScript } = require('../common/debugger-probe');
8+
const { assertProbeJson, probeScript } = require('../common/debugger-probe');
109

1110
spawnSyncAndAssert(process.execPath, [
1211
'inspect',
@@ -16,7 +15,7 @@ spawnSyncAndAssert(process.execPath, [
1615
probeScript,
1716
], {
1817
stdout(output) {
19-
assert.deepStrictEqual(JSON.parse(output), {
18+
assertProbeJson(output, {
2019
v: 1,
2120
probes: [{
2221
expr: 'finalValue',
Collapse file

‎test/parallel/test-debugger-probe-json-preview.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-json-preview.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeTypesScript } = require('../common/debugger-probe');
8+
const {
9+
assertProbeJson,
10+
probeTypesScript,
11+
} = require('../common/debugger-probe');
1012

1113
const location = `${probeTypesScript}:17`;
1214

@@ -23,7 +25,7 @@ spawnSyncAndAssert(process.execPath, [
2325
probeTypesScript,
2426
], {
2527
stdout(output) {
26-
assert.deepStrictEqual(JSON.parse(output), {
28+
assertProbeJson(output, {
2729
v: 1,
2830
probes: [
2931
{ expr: 'objectValue', target: [probeTypesScript, 17] },
Collapse file

‎test/parallel/test-debugger-probe-json-special-values.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-json-special-values.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeTypesScript } = require('../common/debugger-probe');
8+
const {
9+
assertProbeJson,
10+
probeTypesScript,
11+
} = require('../common/debugger-probe');
1012

1113
const location = `${probeTypesScript}:17`;
1214

@@ -38,7 +40,7 @@ spawnSyncAndAssert(process.execPath, [
3840
probeTypesScript,
3941
], {
4042
stdout(output) {
41-
assert.deepStrictEqual(JSON.parse(output), {
43+
assertProbeJson(output, {
4244
v: 1,
4345
probes: [
4446
{ expr: 'stringValue', target: [probeTypesScript, 17] },
Collapse file

‎test/parallel/test-debugger-probe-json.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-json.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeScript } = require('../common/debugger-probe');
8+
const { assertProbeJson, probeScript } = require('../common/debugger-probe');
109

1110
spawnSyncAndAssert(process.execPath, [
1211
'inspect',
@@ -20,7 +19,7 @@ spawnSyncAndAssert(process.execPath, [
2019
probeScript,
2120
], {
2221
stdout(output) {
23-
assert.deepStrictEqual(JSON.parse(output), {
22+
assertProbeJson(output, {
2423
v: 1,
2524
probes: [
2625
{ expr: 'index', target: [probeScript, 8] },
Collapse file

‎test/parallel/test-debugger-probe-miss.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-miss.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { missScript } = require('../common/debugger-probe');
8+
const { assertProbeJson, missScript } = require('../common/debugger-probe');
109

1110
spawnSyncAndAssert(process.execPath, [
1211
'inspect',
@@ -16,7 +15,7 @@ spawnSyncAndAssert(process.execPath, [
1615
missScript,
1716
], {
1817
stdout(output) {
19-
assert.deepStrictEqual(JSON.parse(output), {
18+
assertProbeJson(output, {
2019
v: 1,
2120
probes: [{ expr: '42', target: [missScript, 99] }],
2221
results: [{
Collapse file

‎test/parallel/test-debugger-probe-text-special-values.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-text-special-values.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeTypesScript } = require('../common/debugger-probe');
8+
const {
9+
assertProbeText,
10+
probeTypesScript,
11+
} = require('../common/debugger-probe');
1012

1113
const location = `${probeTypesScript}:17`;
1214

@@ -37,7 +39,7 @@ spawnSyncAndAssert(process.execPath, [
3739
probeTypesScript,
3840
], {
3941
stdout(output) {
40-
assert.strictEqual(output, [
42+
assertProbeText(output, [
4143
`Hit 1 at ${location}`,
4244
' stringValue = "hello"',
4345
`Hit 1 at ${location}`,
Collapse file

‎test/parallel/test-debugger-probe-text.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-text.js
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndAssert } = require('../common/child_process');
9-
const { probeScript } = require('../common/debugger-probe');
8+
const { assertProbeText, probeScript } = require('../common/debugger-probe');
109

1110
spawnSyncAndAssert(process.execPath, [
1211
'inspect',
@@ -15,10 +14,10 @@ spawnSyncAndAssert(process.execPath, [
1514
probeScript,
1615
], {
1716
stdout(output) {
18-
assert.strictEqual(output,
19-
`Hit 1 at ${probeScript}:12\n` +
20-
' finalValue = 81\n' +
21-
'Completed');
17+
assertProbeText(output,
18+
`Hit 1 at ${probeScript}:12\n` +
19+
' finalValue = 81\n' +
20+
'Completed');
2221
},
2322
trim: true,
2423
});
Collapse file

‎test/parallel/test-debugger-probe-timeout.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debugger-probe-timeout.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
const common = require('../common');
55
common.skipIfInspectorDisabled();
66

7-
const assert = require('assert');
87
const { spawnSyncAndExit } = require('../common/child_process');
9-
const { timeoutScript } = require('../common/debugger-probe');
8+
const { assertProbeJson, timeoutScript } = require('../common/debugger-probe');
109

1110
spawnSyncAndExit(process.execPath, [
1211
'inspect',
@@ -19,7 +18,7 @@ spawnSyncAndExit(process.execPath, [
1918
signal: null,
2019
status: 1,
2120
stdout(output) {
22-
assert.deepStrictEqual(JSON.parse(output), {
21+
assertProbeJson(output, {
2322
v: 1,
2423
probes: [{ expr: '1', target: [timeoutScript, 99] }],
2524
results: [{

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.