|
1 | 1 | 'use strict'; |
2 | 2 | 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'); |
10 | 3 |
|
11 | 4 | if (common.isWindows) |
12 | 5 | common.skip('On Windows named pipes live in their own ' + |
13 | 6 | 'filesystem and don\'t have a ~100 byte limit'); |
14 | 7 | if (!common.isMainThread) |
15 | 8 | common.skip('process.chdir is not available in Workers'); |
16 | 9 |
|
| 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 | + |
17 | 18 | // Choose a socket name such that the absolute path would exceed 100 bytes. |
18 | 19 | const socketDir = './unix-socket-dir'; |
19 | 20 | const socketName = 'A'.repeat(100 - socketDir.length - 1); |
20 | 21 |
|
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'); |
24 | 25 |
|
25 | 26 | if (cluster.isMaster) { |
26 | | - // ensure that the worker exits peacefully |
| 27 | + // Ensure that the worker exits peacefully. |
27 | 28 | tmpdir.refresh(); |
28 | 29 | process.chdir(tmpdir.path); |
29 | 30 | fs.mkdirSync(socketDir); |
30 | | - cluster.fork().on('exit', common.mustCall(function(statusCode) { |
| 31 | + cluster.fork().on('exit', common.mustCall((statusCode) => { |
31 | 32 | assert.strictEqual(statusCode, 0); |
32 | 33 |
|
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'); |
36 | 36 | })); |
37 | 37 | } else { |
38 | 38 | process.chdir(socketDir); |
39 | 39 |
|
40 | 40 | const server = net.createServer(common.mustNotCall()); |
41 | 41 |
|
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'); |
46 | 44 |
|
47 | 45 | process.disconnect(); |
48 | 46 | })); |
|
0 commit comments