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: remove a snapshot blob from test-inspect-address-in-use.js · nodejs/node@c87770b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-inspect-address-in-use.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-inspect-address-in-use.js‎

Copy file name to clipboard
+64Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'use strict';
2+
const common = require('../common');
3+
common.skipIfInspectorDisabled();
4+
5+
const { spawnSync } = require('child_process');
6+
const { createServer } = require('http');
7+
const assert = require('assert');
8+
const tmpdir = require('../common/tmpdir');
9+
const fixtures = require('../common/fixtures');
10+
const entry = fixtures.path('empty.js');
11+
const { Worker } = require('worker_threads');
12+
13+
function testOnServerListen(fn) {
14+
const server = createServer((socket) => {
15+
socket.end('echo');
16+
});
17+
18+
server.on('listening', () => {
19+
fn(server);
20+
server.close();
21+
});
22+
server.listen(0, '127.0.0.1');
23+
}
24+
25+
function testChildProcess(getArgs, exitCode, options) {
26+
testOnServerListen((server) => {
27+
const { port } = server.address();
28+
const child = spawnSync(process.execPath, getArgs(port), options);
29+
const stderr = child.stderr.toString().trim();
30+
const stdout = child.stdout.toString().trim();
31+
console.log('[STDERR]');
32+
console.log(stderr);
33+
console.log('[STDOUT]');
34+
console.log(stdout);
35+
const match = stderr.match(
36+
/Starting inspector on 127\.0\.0\.1:(\d+) failed: address already in use/
37+
);
38+
assert.notStrictEqual(match, null);
39+
assert.strictEqual(match[1], port + '');
40+
assert.strictEqual(child.status, exitCode);
41+
});
42+
}
43+
44+
tmpdir.refresh();
45+
46+
testChildProcess(
47+
(port) => [`--inspect=${port}`, '--build-snapshot', entry], 0,
48+
{ cwd: tmpdir.path });
49+
50+
testChildProcess(
51+
(port) => [`--inspect=${port}`, entry], 0);
52+
53+
testOnServerListen((server) => {
54+
const { port } = server.address();
55+
const worker = new Worker(entry, {
56+
execArgv: [`--inspect=${port}`]
57+
});
58+
59+
worker.on('error', common.mustNotCall());
60+
61+
worker.on('exit', common.mustCall((code) => {
62+
assert.strictEqual(code, 0);
63+
}));
64+
});

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.