Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a62345e

Browse filesBrowse files
jasnelladuh95
authored andcommitted
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: #56716 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6edf04e commit a62345e
Copy full SHA for a62345e

File tree

Expand file treeCollapse file tree

7 files changed

+19
-21
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+19
-21
lines changed
Open diff view settings
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
-6Lines changed: 0 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,6 @@ Indicates if [internationalization][] is supported.
238238

239239
Indicates whether `IPv6` is supported on this platform.
240240

241-
### `hasMultiLocalhost`
242-
243-
* [\<boolean>][<boolean>]
244-
245-
Indicates if there are multiple localhosts available.
246-
247241
### `inFreeBSDJail`
248242

249243
* [\<boolean>][<boolean>]
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,6 @@ function _mustCallInner(fn, criteria = 1, field) {
489489
return _return;
490490
}
491491

492-
function hasMultiLocalhost() {
493-
const { internalBinding } = require('internal/test/binding');
494-
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
495-
const t = new TCP(TCPConstants.SOCKET);
496-
const ret = t.bind('127.0.0.2', 0);
497-
t.close();
498-
return ret === 0;
499-
}
500-
501492
function skipIfEslintMissing() {
502493
if (!fs.existsSync(
503494
path.join(__dirname, '..', '..', 'tools', 'eslint', 'node_modules', 'eslint'),
@@ -965,7 +956,6 @@ const common = {
965956
hasIntl,
966957
hasCrypto,
967958
hasQuic,
968-
hasMultiLocalhost,
969959
invalidArgTypeHelper,
970960
isAlive,
971961
isASan,
Collapse file

‎test/common/index.mjs‎

Copy file name to clipboardExpand all lines: test/common/index.mjs
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const {
2020
hasCrypto,
2121
hasIntl,
2222
hasIPv6,
23-
hasMultiLocalhost,
2423
isAIX,
2524
isAlive,
2625
isDumbTerminal,
@@ -75,7 +74,6 @@ export {
7574
hasCrypto,
7675
hasIntl,
7776
hasIPv6,
78-
hasMultiLocalhost,
7977
isAIX,
8078
isAlive,
8179
isDumbTerminal,
Collapse file

‎test/common/net.js‎

Copy file name to clipboardExpand all lines: test/common/net.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@ function checkSupportReusePort() {
1717
});
1818
}
1919

20+
function hasMultiLocalhost() {
21+
const { internalBinding } = require('internal/test/binding');
22+
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
23+
const t = new TCP(TCPConstants.SOCKET);
24+
const ret = t.bind('127.0.0.2', 0);
25+
t.close();
26+
return ret === 0;
27+
}
28+
2029
module.exports = {
2130
checkSupportReusePort,
31+
hasMultiLocalhost,
2232
options,
2333
};
Collapse file

‎test/parallel/test-http-localaddress.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-localaddress.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
// Flags: --expose-internals
2323
'use strict';
2424
const common = require('../common');
25-
if (!common.hasMultiLocalhost())
25+
const { hasMultiLocalhost } = require('../common/net');
26+
if (!hasMultiLocalhost()) {
2627
common.skip('platform-specific test.');
28+
}
2729

2830
const http = require('http');
2931
const assert = require('assert');
Collapse file

‎test/parallel/test-http2-connect-options.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-connect-options.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
66

7-
if (!common.hasMultiLocalhost())
7+
const { hasMultiLocalhost } = require('../common/net');
8+
if (!hasMultiLocalhost()) {
89
common.skip('platform-specific test.');
10+
}
911

1012
const http2 = require('http2');
1113
const assert = require('assert');
Collapse file

‎test/parallel/test-https-localaddress.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-https-localaddress.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const common = require('../common');
2525
if (!common.hasCrypto)
2626
common.skip('missing crypto');
2727

28-
if (!common.hasMultiLocalhost())
28+
const { hasMultiLocalhost } = require('../common/net');
29+
if (!hasMultiLocalhost()) {
2930
common.skip('platform-specific test.');
31+
}
3032

3133
const fixtures = require('../common/fixtures');
3234
const assert = require('assert');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.