node/test/parallel/test-process-external-stdio-close-spawn.js
Matteo Collina 330c8d743e stream: add destroy and _destroy methods.
Adds destroy() and _destroy() methods to Readable, Writable, Duplex
and Transform. It also standardizes the behavior and the implementation
of destroy(), which has been inconsistent in userland and core.
This PR also updates all the subsystems of core to use the new
destroy().

PR-URL: https://github.com/nodejs/node/pull/12925
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-05-22 08:34:14 +02:00

32 lines
1.0 KiB
JavaScript

'use strict';
// Refs: https://github.com/nodejs/node/issues/947
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
if (process.argv[2] === 'child') {
process.on('message', common.mustCall((msg) => {
assert.strictEqual(msg, 'go');
// the following console.log is an integral part
// of the test. If this regress, this call will
// cause the process to exit with 1
console.log('logging should not cause a crash');
process.disconnect();
}));
} else {
// Passing '--inspect', '--inspect-brk' to child.spawn enables
// the debugger. This test was added to help debug the fork-based
// test with the same name.
const child = cp.spawn(process.execPath, [__filename, 'child'], {
stdio: ['pipe', 'pipe', 'pipe', 'ipc']
});
child.on('close', common.mustCall((exitCode, signal) => {
assert.strictEqual(exitCode, 0, 'exit successfully');
assert.strictEqual(signal, null);
}));
child.stdout.destroy();
child.send('go');
}