node/test/parallel/test-child-process-fork-stdio-string-variant.js
Sebastiaan Deckers bb29405904
lib,src: fix consistent spacing inside braces
PR-URL: https://github.com/nodejs/node/pull/14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-21 15:13:47 -04:00

31 lines
929 B
JavaScript

'use strict';
const common = require('../common');
// Ensures that child_process.fork can accept string
// variant of stdio parameter in options object and
// throws a TypeError when given an unexpected string
const assert = require('assert');
const fork = require('child_process').fork;
const childScript = `${common.fixturesDir}/child-process-spawn-node`;
const errorRegexp = /^TypeError: Incorrect value of stdio option:/;
const malFormedOpts = { stdio: '33' };
const payload = { hello: 'world' };
assert.throws(() => fork(childScript, malFormedOpts), errorRegexp);
function test(stringVariant) {
const child = fork(childScript, { stdio: stringVariant });
child.on('message', common.mustCall((message) => {
assert.deepStrictEqual(message, { foo: 'bar' });
}));
child.send(payload);
child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));
}
['pipe', 'inherit', 'ignore'].forEach(test);