mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
test: move hasMultiLocalhost to common/net
Given that `common/net` already exists and hasMultiLocalhost is net specific, let's move it out of common/index to better encapsulate and simplify common/index more PR-URL: https://github.com/nodejs/node/pull/56716 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
761de815c5
commit
f07300cfa3
7 changed files with 19 additions and 21 deletions
|
@ -238,12 +238,6 @@ Indicates if [internationalization][] is supported.
|
|||
|
||||
Indicates whether `IPv6` is supported on this platform.
|
||||
|
||||
### `hasMultiLocalhost`
|
||||
|
||||
* [\<boolean>][<boolean>]
|
||||
|
||||
Indicates if there are multiple localhosts available.
|
||||
|
||||
### `inFreeBSDJail`
|
||||
|
||||
* [\<boolean>][<boolean>]
|
||||
|
|
|
@ -489,15 +489,6 @@ function _mustCallInner(fn, criteria = 1, field) {
|
|||
return _return;
|
||||
}
|
||||
|
||||
function hasMultiLocalhost() {
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||
const t = new TCP(TCPConstants.SOCKET);
|
||||
const ret = t.bind('127.0.0.2', 0);
|
||||
t.close();
|
||||
return ret === 0;
|
||||
}
|
||||
|
||||
function skipIfEslintMissing() {
|
||||
if (!fs.existsSync(
|
||||
path.join(__dirname, '..', '..', 'tools', 'eslint', 'node_modules', 'eslint'),
|
||||
|
@ -965,7 +956,6 @@ const common = {
|
|||
hasIntl,
|
||||
hasCrypto,
|
||||
hasQuic,
|
||||
hasMultiLocalhost,
|
||||
invalidArgTypeHelper,
|
||||
isAlive,
|
||||
isASan,
|
||||
|
|
|
@ -20,7 +20,6 @@ const {
|
|||
hasCrypto,
|
||||
hasIntl,
|
||||
hasIPv6,
|
||||
hasMultiLocalhost,
|
||||
isAIX,
|
||||
isAlive,
|
||||
isDumbTerminal,
|
||||
|
@ -75,7 +74,6 @@ export {
|
|||
hasCrypto,
|
||||
hasIntl,
|
||||
hasIPv6,
|
||||
hasMultiLocalhost,
|
||||
isAIX,
|
||||
isAlive,
|
||||
isDumbTerminal,
|
||||
|
|
|
@ -17,7 +17,17 @@ function checkSupportReusePort() {
|
|||
});
|
||||
}
|
||||
|
||||
function hasMultiLocalhost() {
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||
const t = new TCP(TCPConstants.SOCKET);
|
||||
const ret = t.bind('127.0.0.2', 0);
|
||||
t.close();
|
||||
return ret === 0;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
checkSupportReusePort,
|
||||
hasMultiLocalhost,
|
||||
options,
|
||||
};
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
if (!common.hasMultiLocalhost())
|
||||
const { hasMultiLocalhost } = require('../common/net');
|
||||
if (!hasMultiLocalhost()) {
|
||||
common.skip('platform-specific test.');
|
||||
}
|
||||
|
||||
const http = require('http');
|
||||
const assert = require('assert');
|
||||
|
|
|
@ -4,8 +4,10 @@ const common = require('../common');
|
|||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
if (!common.hasMultiLocalhost())
|
||||
const { hasMultiLocalhost } = require('../common/net');
|
||||
if (!hasMultiLocalhost()) {
|
||||
common.skip('platform-specific test.');
|
||||
}
|
||||
|
||||
const http2 = require('http2');
|
||||
const assert = require('assert');
|
||||
|
|
|
@ -25,8 +25,10 @@ const common = require('../common');
|
|||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
if (!common.hasMultiLocalhost())
|
||||
const { hasMultiLocalhost } = require('../common/net');
|
||||
if (!hasMultiLocalhost()) {
|
||||
common.skip('platform-specific test.');
|
||||
}
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue