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 46d14fc

Browse filesBrowse files
Trotttargos
authored andcommitted
test: refactor cluster-net-listen-relative-path
Refactor test-cluster-net-listen-relative-path: * Use arrow funcitons for callbacks. * Move skip-test code closer to start of file. * Use assert.ok() where appropriate. * Capitalize and punctuate comments. PR-URL: #21863 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent f89d194 commit 46d14fc
Copy full SHA for 46d14fc

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎test/parallel/test-cluster-net-listen-relative-path.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-net-listen-relative-path.js
+17-19Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
4-
const cluster = require('cluster');
5-
const net = require('net');
6-
const path = require('path');
7-
const fs = require('fs');
8-
9-
const tmpdir = require('../common/tmpdir');
103

114
if (common.isWindows)
125
common.skip('On Windows named pipes live in their own ' +
136
'filesystem and don\'t have a ~100 byte limit');
147
if (!common.isMainThread)
158
common.skip('process.chdir is not available in Workers');
169

10+
const assert = require('assert');
11+
const cluster = require('cluster');
12+
const fs = require('fs');
13+
const net = require('net');
14+
const path = require('path');
15+
16+
const tmpdir = require('../common/tmpdir');
17+
1718
// Choose a socket name such that the absolute path would exceed 100 bytes.
1819
const socketDir = './unix-socket-dir';
1920
const socketName = 'A'.repeat(100 - socketDir.length - 1);
2021

21-
// Make sure we're not in a weird environment
22-
assert.strictEqual(path.resolve(socketDir, socketName).length > 100, true,
23-
'absolute socket path should be longer than 100 bytes');
22+
// Make sure we're not in a weird environment.
23+
assert.ok(path.resolve(socketDir, socketName).length > 100,
24+
'absolute socket path should be longer than 100 bytes');
2425

2526
if (cluster.isMaster) {
26-
// ensure that the worker exits peacefully
27+
// Ensure that the worker exits peacefully.
2728
tmpdir.refresh();
2829
process.chdir(tmpdir.path);
2930
fs.mkdirSync(socketDir);
30-
cluster.fork().on('exit', common.mustCall(function(statusCode) {
31+
cluster.fork().on('exit', common.mustCall((statusCode) => {
3132
assert.strictEqual(statusCode, 0);
3233

33-
assert.strictEqual(
34-
fs.existsSync(path.join(socketDir, socketName)), false,
35-
'Socket should be removed when the worker exits');
34+
assert.ok(!fs.existsSync(path.join(socketDir, socketName)),
35+
'Socket should be removed when the worker exits');
3636
}));
3737
} else {
3838
process.chdir(socketDir);
3939

4040
const server = net.createServer(common.mustNotCall());
4141

42-
server.listen(socketName, common.mustCall(function() {
43-
assert.strictEqual(
44-
fs.existsSync(socketName), true,
45-
'Socket created in CWD');
42+
server.listen(socketName, common.mustCall(() => {
43+
assert.ok(fs.existsSync(socketName), 'Socket created in CWD');
4644

4745
process.disconnect();
4846
}));

0 commit comments

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