| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cb5986d commit 0178001
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,47 +1,29 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - // Flags: --expose-internals | ||
| 2 | + | ||
| 3 | + // Test fails in Node v5.4.0 and passes in v5.4.1 and newer. | ||
| 3 | 4 | ||
| 4 | 5 | const common = require('../common'); | |
| 5 | - const assert = require('assert'); | ||
| 6 | 6 | const net = require('net'); | |
| 7 | 7 | const cluster = require('cluster'); | |
| 8 | - const handles = require('internal/cluster').handles; | ||
| 9 | - const os = require('os'); | ||
| 10 | 8 | ||
| 11 | - if (common.isWindows) { | ||
| 12 | - console.log('1..0 # Skipped: This test does not apply to Windows.'); | ||
| 13 | - return; | ||
| 14 | - } | ||
| 9 | + const noop = () => {}; | ||
| 15 | 10 | ||
| 16 | 11 | cluster.schedulingPolicy = cluster.SCHED_NONE; | |
| 17 | 12 | ||
| 18 | 13 | if (cluster.isMaster) { | |
| 19 | - const cpus = os.cpus().length; | ||
| 20 | - const tries = cpus > 8 ? 128 : cpus * 16; | ||
| 21 | - | ||
| 22 | - const worker1 = cluster.fork(); | ||
| 23 | - worker1.on('message', common.mustCall(() => { | ||
| 24 | - worker1.disconnect(); | ||
| 25 | - for (let i = 0; i < tries; ++ i) { | ||
| 26 | - const w = cluster.fork(); | ||
| 27 | - w.on('online', common.mustCall(w.disconnect)); | ||
| 28 | - } | ||
| 29 | - })); | ||
| 30 | - | ||
| 31 | - cluster.on('exit', common.mustCall((worker, code) => { | ||
| 32 | - assert.strictEqual(code, 0, 'worker exited with error'); | ||
| 33 | - }, tries + 1)); | ||
| 34 | - | ||
| 35 | - process.on('exit', () => { | ||
| 36 | - assert.deepEqual(Object.keys(cluster.workers), []); | ||
| 37 | - assert.strictEqual(Object.keys(handles).length, 0); | ||
| 38 | - }); | ||
| 14 | + const worker = cluster.fork(); | ||
| 15 | + | ||
| 16 | + // This is the important part of the test: Confirm that `disconnect` fires. | ||
| 17 | + worker.on('disconnect', common.mustCall(noop)); | ||
| 18 | + | ||
| 19 | + // These are just some extra stuff we're checking for good measure... | ||
| 20 | + worker.on('exit', common.mustCall(noop)); | ||
| 21 | + cluster.on('exit', common.mustCall(noop)); | ||
| 39 | 22 | ||
| 23 | + cluster.disconnect(); | ||
| 40 | 24 | return; | |
| 41 | 25 | } | |
| 42 | 26 | ||
| 43 | - var server = net.createServer(); | ||
| 27 | + const server = net.createServer(); | ||
| 44 | 28 | ||
| 45 | - server.listen(common.PORT, function() { | ||
| 46 | - process.send('listening'); | ||
| 47 | - }); | ||
| 29 | + server.listen(common.PORT); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments