Skip to content

Commit b200a46

Browse files
joyeecheungdanbev
authored andcommitted
src: remove process.binding('config').debugOptions
`process.binding('config').debugOptions`, which contains the initial values of parsed debugger-related CLI options, has been used for internal testing. This patch removes them and uses `internal/options` to query the values in the tests instead. PR-URL: #25999 Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a993160 commit b200a46

File tree

2 files changed

+78
-87
lines changed

2 files changed

+78
-87
lines changed

src/node_config.cc

-15
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
namespace node {
88

9-
using v8::Boolean;
109
using v8::Context;
11-
using v8::Integer;
1210
using v8::Isolate;
1311
using v8::Local;
1412
using v8::Number;
@@ -72,19 +70,6 @@ static void Initialize(Local<Object> target,
7270
READONLY_PROPERTY(target,
7371
"bits",
7472
Number::New(env->isolate(), 8 * sizeof(intptr_t)));
75-
76-
Local<Object> debug_options_obj = Object::New(isolate);
77-
READONLY_PROPERTY(target, "debugOptions", debug_options_obj);
78-
79-
const DebugOptions& debug_options = env->options()->debug_options();
80-
READONLY_PROPERTY(debug_options_obj,
81-
"inspectorEnabled",
82-
Boolean::New(isolate, debug_options.inspector_enabled));
83-
READONLY_STRING_PROPERTY(
84-
debug_options_obj, "host", debug_options.host_port.host());
85-
READONLY_PROPERTY(debug_options_obj,
86-
"port",
87-
Integer::New(isolate, debug_options.host_port.port()));
8873
} // InitConfig
8974

9075
} // namespace node

test/sequential/test-inspector-port-cluster.js

+78-72
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// Flags: --expose-internals
4+
35
const common = require('../common');
46

57
common.skipIfInspectorDisabled();
@@ -205,7 +207,7 @@ function testRunnerMain() {
205207
}
206208
function masterProcessMain() {
207209
const workers = JSON.parse(process.env.workers);
208-
const clusterSettings = JSON.parse(process.env.clusterSettings);
210+
const clusterSettings = JSON.parse(process.env.clusterSettings) || {};
209211
const badPortError = { type: RangeError, code: 'ERR_SOCKET_BAD_PORT' };
210212
let debugPort = process.debugPort;
211213

@@ -224,85 +226,89 @@ function masterProcessMain() {
224226
params.expectedHost = worker.expectedHost;
225227
}
226228

227-
if (clusterSettings) {
228-
if (clusterSettings.inspectPort === 'addTwo') {
229-
clusterSettings.inspectPort = common.mustCall(
230-
() => { return debugPort += 2; },
231-
workers.length
232-
);
233-
} else if (clusterSettings.inspectPort === 'string') {
234-
clusterSettings.inspectPort = 'string';
235-
cluster.setupMaster(clusterSettings);
236-
237-
common.expectsError(() => {
238-
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
239-
}, badPortError);
240-
241-
return;
242-
} else if (clusterSettings.inspectPort === 'null') {
243-
clusterSettings.inspectPort = null;
244-
cluster.setupMaster(clusterSettings);
245-
246-
common.expectsError(() => {
247-
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
248-
}, badPortError);
249-
250-
return;
251-
} else if (clusterSettings.inspectPort === 'bignumber') {
252-
clusterSettings.inspectPort = 1293812;
253-
cluster.setupMaster(clusterSettings);
254-
255-
common.expectsError(() => {
256-
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
257-
}, badPortError);
258-
259-
return;
260-
} else if (clusterSettings.inspectPort === 'negativenumber') {
261-
clusterSettings.inspectPort = -9776;
262-
cluster.setupMaster(clusterSettings);
263-
264-
common.expectsError(() => {
265-
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
266-
}, badPortError);
267-
268-
return;
269-
} else if (clusterSettings.inspectPort === 'bignumberfunc') {
270-
clusterSettings.inspectPort = common.mustCall(
271-
() => 123121,
272-
workers.length
273-
);
274-
275-
cluster.setupMaster(clusterSettings);
276-
277-
common.expectsError(() => {
278-
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
279-
}, badPortError);
280-
281-
return;
282-
} else if (clusterSettings.inspectPort === 'strfunc') {
283-
clusterSettings.inspectPort = common.mustCall(
284-
() => 'invalidPort',
285-
workers.length
286-
);
287-
288-
cluster.setupMaster(clusterSettings);
289-
290-
common.expectsError(() => {
291-
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
292-
}, badPortError);
293-
294-
return;
295-
}
229+
clusterSettings.execArgv = clusterSettings.execArgv ?
230+
clusterSettings.execArgv.concat(['--expose-internals']) :
231+
process.execArgv.concat(['--expose-internals']);
232+
233+
if (clusterSettings.inspectPort === 'addTwo') {
234+
clusterSettings.inspectPort = common.mustCall(
235+
() => { return debugPort += 2; },
236+
workers.length
237+
);
238+
} else if (clusterSettings.inspectPort === 'string') {
239+
clusterSettings.inspectPort = 'string';
240+
cluster.setupMaster(clusterSettings);
241+
242+
common.expectsError(() => {
243+
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
244+
}, badPortError);
245+
246+
return;
247+
} else if (clusterSettings.inspectPort === 'null') {
248+
clusterSettings.inspectPort = null;
296249
cluster.setupMaster(clusterSettings);
250+
251+
common.expectsError(() => {
252+
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
253+
}, badPortError);
254+
255+
return;
256+
} else if (clusterSettings.inspectPort === 'bignumber') {
257+
clusterSettings.inspectPort = 1293812;
258+
cluster.setupMaster(clusterSettings);
259+
260+
common.expectsError(() => {
261+
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
262+
}, badPortError);
263+
264+
return;
265+
} else if (clusterSettings.inspectPort === 'negativenumber') {
266+
clusterSettings.inspectPort = -9776;
267+
cluster.setupMaster(clusterSettings);
268+
269+
common.expectsError(() => {
270+
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
271+
}, badPortError);
272+
273+
return;
274+
} else if (clusterSettings.inspectPort === 'bignumberfunc') {
275+
clusterSettings.inspectPort = common.mustCall(
276+
() => 123121,
277+
workers.length
278+
);
279+
280+
cluster.setupMaster(clusterSettings);
281+
282+
common.expectsError(() => {
283+
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
284+
}, badPortError);
285+
286+
return;
287+
} else if (clusterSettings.inspectPort === 'strfunc') {
288+
clusterSettings.inspectPort = common.mustCall(
289+
() => 'invalidPort',
290+
workers.length
291+
);
292+
293+
cluster.setupMaster(clusterSettings);
294+
295+
common.expectsError(() => {
296+
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
297+
}, badPortError);
298+
299+
return;
297300
}
298301

302+
cluster.setupMaster(clusterSettings);
303+
299304
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
300305
}
301306
}
302307

303308
function workerProcessMain() {
304309
const { expectedPort, expectedInitialPort, expectedHost } = process.env;
305-
const debugOptions = process.binding('config').debugOptions;
310+
const debugOptions =
311+
require('internal/options').getOptionValue('--inspect-port');
306312

307313
if ('expectedPort' in process.env) {
308314
assert.strictEqual(process.debugPort, +expectedPort);
@@ -327,7 +333,7 @@ function spawnMaster({ execArgv, workers, clusterSettings = {} }) {
327333
clusterSettings: JSON.stringify(clusterSettings),
328334
testProcess: true
329335
}),
330-
execArgv
336+
execArgv: execArgv.concat(['--expose-internals'])
331337
}).on('exit', common.mustCall((code, signal) => {
332338
checkExitCode(code, signal);
333339
resolve();

0 commit comments

Comments
 (0)