Skip to content

test: move hasMultiLocalhost to common/net #56716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,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>]
Expand Down
10 changes: 0 additions & 10 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,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'),
Expand Down Expand Up @@ -987,7 +978,6 @@ const common = {
hasCrypto,
hasOpenSSL,
hasQuic,
hasMultiLocalhost,
invalidArgTypeHelper,
isAlive,
isASan,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const {
hasCrypto,
hasIntl,
hasIPv6,
hasMultiLocalhost,
isAIX,
isAlive,
isDumbTerminal,
Expand Down Expand Up @@ -76,7 +75,6 @@ export {
hasCrypto,
hasIntl,
hasIPv6,
hasMultiLocalhost,
isAIX,
isAlive,
isDumbTerminal,
Expand Down
10 changes: 10 additions & 0 deletions test/common/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
4 changes: 3 additions & 1 deletion test/parallel/test-http-localaddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-http2-connect-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-https-localaddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading