summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-01-26 14:16:20 -0500
committercjihrig <cjihrig@gmail.com>2018-01-29 10:24:45 -0500
commite0864e50ecf917cbfa98d443e6f122425d6447cf (patch)
tree37b38c48a4c91d5f9eed9675c705125e3d5dff77 /test
parent0778f79cb37526c3f4f8bff525fc4d4ca9b86e78 (diff)
downloadandroid-node-v8-e0864e50ecf917cbfa98d443e6f122425d6447cf.tar.gz
android-node-v8-e0864e50ecf917cbfa98d443e6f122425d6447cf.tar.bz2
android-node-v8-e0864e50ecf917cbfa98d443e6f122425d6447cf.zip
cluster: add cwd to cluster.settings
This commit allows cluster workers to be created with configurable working directories. Fixes: https://github.com/nodejs/node/issues/16388 PR-URL: https://github.com/nodejs/node/pull/18399 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-cluster-cwd.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/parallel/test-cluster-cwd.js b/test/parallel/test-cluster-cwd.js
new file mode 100644
index 0000000000..ce3fdca51e
--- /dev/null
+++ b/test/parallel/test-cluster-cwd.js
@@ -0,0 +1,22 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+
+if (cluster.isMaster) {
+ common.refreshTmpDir();
+
+ assert.strictEqual(cluster.settings.cwd, undefined);
+ cluster.fork().on('message', common.mustCall((msg) => {
+ assert.strictEqual(msg, process.cwd());
+ }));
+
+ cluster.setupMaster({ cwd: common.tmpDir });
+ assert.strictEqual(cluster.settings.cwd, common.tmpDir);
+ cluster.fork().on('message', common.mustCall((msg) => {
+ assert.strictEqual(msg, common.tmpDir);
+ }));
+} else {
+ process.send(process.cwd());
+ process.disconnect();
+}