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 8778fca

Browse filesBrowse files
jBarzItalo A. Casas
authored andcommitted
test: check fd 0,1,2 are used, not access mode
Don't do a write on stdout/stderr because that checks for their writability. But fd=1 could legitimately be opened with read-only access by the user. All this test needs to ensure is that they are used at startup. PR-URL: #10339 Fixes: #10234 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 84e2ff3 commit 8778fca
Copy full SHA for 8778fca

File tree

Expand file treeCollapse file tree

1 file changed

+3
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-16
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-stdio-closed.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stdio-closed.js
+3-16Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,15 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const spawn = require('child_process').spawn;
5+
const fs = require('fs');
56

67
if (common.isWindows) {
78
common.skip('platform not supported.');
89
return;
910
}
1011

1112
if (process.argv[2] === 'child') {
12-
try {
13-
process.stdout.write('stdout', function() {
14-
try {
15-
process.stderr.write('stderr', function() {
16-
process.exit(42);
17-
});
18-
} catch (e) {
19-
process.exit(84);
20-
}
21-
});
22-
} catch (e) {
23-
assert.strictEqual(e.code, 'EBADF');
24-
assert.strictEqual(e.message, 'EBADF: bad file descriptor, write');
25-
process.exit(126);
26-
}
13+
[0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));
2714
return;
2815
}
2916

@@ -32,5 +19,5 @@ const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
3219
const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
3320

3421
proc.on('exit', common.mustCall(function(exitCode) {
35-
assert.strictEqual(exitCode, common.isAix ? 126 : 42);
22+
assert.strictEqual(exitCode, 0);
3623
}));

0 commit comments

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