node/test/parallel/test-cluster-cwd.js
Rich Trott bf6ce47259 test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir).

PR-URL: https://github.com/nodejs/node/pull/17856
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-01-31 22:11:07 -08:00

24 lines
651 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const tmpdir = require('../common/tmpdir');
if (cluster.isMaster) {
tmpdir.refresh();
assert.strictEqual(cluster.settings.cwd, undefined);
cluster.fork().on('message', common.mustCall((msg) => {
assert.strictEqual(msg, process.cwd());
}));
cluster.setupMaster({ cwd: tmpdir.path });
assert.strictEqual(cluster.settings.cwd, tmpdir.path);
cluster.fork().on('message', common.mustCall((msg) => {
assert.strictEqual(msg, tmpdir.path);
}));
} else {
process.send(process.cwd());
process.disconnect();
}