11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../../common');
41cb0ef41Sopenharmony_ciconst fixtures = require('../../common/fixtures');
51cb0ef41Sopenharmony_ciconst { run } = require('node:test');
61cb0ef41Sopenharmony_ciconst assert = require('node:assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst badPortError = { name: 'RangeError', code: 'ERR_SOCKET_BAD_PORT' };
91cb0ef41Sopenharmony_cilet inspectPort = 'inspectPort' in process.env ? Number(process.env.inspectPort) : undefined;
101cb0ef41Sopenharmony_cilet expectedError;
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciif (process.env.inspectPort === 'addTwo') {
131cb0ef41Sopenharmony_ci  inspectPort = common.mustCall(() => { return process.debugPort += 2; });
141cb0ef41Sopenharmony_ci} else if (process.env.inspectPort === 'string') {
151cb0ef41Sopenharmony_ci  inspectPort = 'string';
161cb0ef41Sopenharmony_ci  expectedError = badPortError;
171cb0ef41Sopenharmony_ci} else if (process.env.inspectPort === 'null') {
181cb0ef41Sopenharmony_ci  inspectPort = null;
191cb0ef41Sopenharmony_ci} else if (process.env.inspectPort === 'bignumber') {
201cb0ef41Sopenharmony_ci  inspectPort = 1293812;
211cb0ef41Sopenharmony_ci  expectedError = badPortError;
221cb0ef41Sopenharmony_ci} else if (process.env.inspectPort === 'negativenumber') {
231cb0ef41Sopenharmony_ci  inspectPort = -9776;
241cb0ef41Sopenharmony_ci  expectedError = badPortError;
251cb0ef41Sopenharmony_ci} else if (process.env.inspectPort === 'bignumberfunc') {
261cb0ef41Sopenharmony_ci  inspectPort = common.mustCall(() => 123121);
271cb0ef41Sopenharmony_ci  expectedError = badPortError;
281cb0ef41Sopenharmony_ci} else if (process.env.inspectPort === 'strfunc') {
291cb0ef41Sopenharmony_ci  inspectPort = common.mustCall(() => 'invalidPort');
301cb0ef41Sopenharmony_ci  expectedError = badPortError;
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciconst stream = run({ files: [fixtures.path('test-runner/run_inspect_assert.js')], inspectPort });
341cb0ef41Sopenharmony_ciif (expectedError) {
351cb0ef41Sopenharmony_ci  stream.on('test:fail', common.mustCall(({ details }) => {
361cb0ef41Sopenharmony_ci    assert.deepStrictEqual({ name: details.error.cause.name, code: details.error.cause.code }, expectedError);
371cb0ef41Sopenharmony_ci  }));
381cb0ef41Sopenharmony_ci} else {
391cb0ef41Sopenharmony_ci  stream.on('test:fail', common.mustNotCall());
401cb0ef41Sopenharmony_ci}
41