mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
dac5f29691
It is flaky due to the same cause of test-child-process-pipe-dataflow being flaky - cygwin quirks - so skip it on Windows too. Drive-by: remove the skip mark of test-child-process-pipe-dataflow in the status file and directly skip it in the test with a comment. PR-URL: https://github.com/nodejs/node/pull/49621 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
'use strict';
|
||
const common = require('../common');
|
||
|
||
if (common.isWindows) {
|
||
// https://github.com/nodejs/node/issues/48300
|
||
common.skip('Does not work with cygwin quirks on Windows');
|
||
}
|
||
|
||
const assert = require('assert');
|
||
const { spawn } = require('child_process');
|
||
|
||
// Check that, once a child process has ended, it’s safe to read from a pipe
|
||
// that the child had used as input.
|
||
// We simulate that using cat | (head -n1; ...)
|
||
|
||
const p1 = spawn('cat', { stdio: ['pipe', 'pipe', 'inherit'] });
|
||
const p2 = spawn('head', ['-n1'], { stdio: [p1.stdout, 'pipe', 'inherit'] });
|
||
|
||
// First, write the line that gets passed through p2, making 'head' exit.
|
||
p1.stdin.write('hello\n');
|
||
p2.stdout.setEncoding('utf8');
|
||
p2.stdout.on('data', common.mustCall((chunk) => {
|
||
assert.strictEqual(chunk, 'hello\n');
|
||
}));
|
||
p2.on('exit', common.mustCall(() => {
|
||
// We can now use cat’s output, because 'head' is no longer reading from it.
|
||
p1.stdin.end('world\n');
|
||
p1.stdout.setEncoding('utf8');
|
||
p1.stdout.on('data', common.mustCall((chunk) => {
|
||
assert.strictEqual(chunk, 'world\n');
|
||
}));
|
||
p1.stdout.resume();
|
||
}));
|