Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d59be4d

Browse filesBrowse files
TrottMyles Borins
authored andcommitted
test: ensure _handle property existence
`test-stdtout-close-unref.js` will fail if `process.stdin._handle` does not exist. On UNIX-like operating systems, you can see this failure this way: ./node test/parallel/test-stdout-close-unref.js < /dev/null This issue has been experienced by @bengl and @drewfish in a Docker container. I'm not sure why they are experiencing it in their environment, but since it is possible that the `_handle` property does not exist, let's use `child_process.spawn()` to make sure it exists. PR-URL: #5916 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 02401a6 commit d59be4d
Copy full SHA for d59be4d

File tree

Expand file treeCollapse file tree

1 file changed

+26
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-12
lines changed
Open diff view settings
Collapse file
+26-12Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
'use strict';
2-
require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const spawn = require('child_process').spawn;
45

5-
var errs = 0;
6+
if (process.argv[2] === 'child') {
7+
var errs = 0;
68

7-
process.stdin.resume();
8-
process.stdin._handle.close();
9-
process.stdin._handle.unref(); // Should not segfault.
10-
process.stdin.on('error', function(err) {
11-
errs++;
12-
});
9+
process.stdin.resume();
10+
process.stdin._handle.close();
11+
process.stdin._handle.unref(); // Should not segfault.
12+
process.stdin.on('error', function(err) {
13+
errs++;
14+
});
1315

14-
process.on('exit', function() {
15-
assert.strictEqual(errs, 1);
16-
});
16+
process.on('exit', function() {
17+
assert.strictEqual(errs, 1);
18+
});
19+
return;
20+
}
21+
22+
// Use spawn so that we can be sure that stdin has a _handle property.
23+
// Refs: https://github.com/nodejs/node/pull/5916
24+
const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'pipe' });
25+
26+
proc.stderr.pipe(process.stderr);
27+
proc.on('exit', common.mustCall(function(exitCode) {
28+
if (exitCode !== 0)
29+
process.exitCode = exitCode;
30+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.