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: watch mode inspect restart repeatedly · nodejs/node@a8030b9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/sequential
    • test-watch-mode-inspect.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/sequential/test-watch-mode-inspect.mjs‎

Copy file name to clipboardExpand all lines: test/sequential/test-watch-mode-inspect.mjs
+17-5Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs';
33
import assert from 'node:assert';
44
import { describe, it } from 'node:test';
55
import { writeFileSync, readFileSync } from 'node:fs';
6+
import { setTimeout } from 'node:timers/promises';
67
import { NodeInstance } from '../common/inspector-helper.js';
78

89

@@ -11,6 +12,12 @@ if (common.isIBMi)
1112

1213
common.skipIfInspectorDisabled();
1314

15+
function restart(file) {
16+
writeFileSync(file, readFileSync(file));
17+
const interval = setInterval(() => writeFileSync(file, readFileSync(file)), 500);
18+
return () => clearInterval(interval);
19+
}
20+
1421
describe('watch mode - inspect', () => {
1522
async function getDebuggedPid(instance, waitForLog = true) {
1623
const session = await instance.connectInspectorSession();
@@ -29,20 +36,25 @@ describe('watch mode - inspect', () => {
2936
const file = fixtures.path('watch-mode/inspect.js');
3037
const instance = new NodeInstance(['--inspect=0', '--watch'], undefined, file);
3138
let stderr = '';
39+
const stdout = [];
3240
instance.on('stderr', (data) => { stderr += data; });
41+
instance.on('stdout', (data) => { stdout.push(data); });
3342

3443
const pids = [instance.pid];
3544
pids.push(await getDebuggedPid(instance));
3645
instance.resetPort();
37-
writeFileSync(file, readFileSync(file));
46+
const stopRestarting = restart(file);
3847
pids.push(await getDebuggedPid(instance));
48+
stopRestarting();
3949

50+
await setTimeout(common.platformTimeout(500));
4051
await instance.kill();
4152

42-
// There should be 3 pids (one parent + 2 restarts).
43-
// Message about Debugger should only appear twice.
44-
assert.strictEqual(stderr.match(/Debugger listening on ws:\/\//g).length, 2);
45-
assert.strictEqual(new Set(pids).size, 3);
53+
// There should be a process per restart and one per parent process.
54+
// Message about Debugger should appear once per restart.
55+
const restarts = stdout.filter((line) => line === 'safe to debug now').length;
56+
assert.strictEqual(stderr.match(/Debugger listening on ws:\/\//g).length, restarts);
57+
assert.strictEqual(new Set(pids).size, restarts + 1);
4658
});
4759

4860
it('should prevent attaching debugger with SIGUSR1 to outer process', { skip: common.isWindows }, async () => {

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.