-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: accept expected AIX result test-stdio-closed
AIX handles closed stdio differently (but still compliant with spec as far as I can tell) than other POSIX variants we test. Test results are different than Linux and others because AIX takes measures to not re-use the file descriptors for stdio if one of the stdio streams is closed. Fixes: #8375 PR-URL: #8755 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Conflicts: test/parallel/parallel.status
- Loading branch information
1 parent
d69570d
commit 5e4d898
Showing
2 changed files
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var spawn = require('child_process').spawn; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const spawn = require('child_process').spawn; | ||
|
||
if (common.isWindows) { | ||
common.skip('platform not supported.'); | ||
return; | ||
} | ||
|
||
if (process.argv[2] === 'child') { | ||
process.stdout.write('stdout', function() { | ||
process.stderr.write('stderr', function() { | ||
process.exit(42); | ||
try { | ||
process.stdout.write('stdout', function() { | ||
try { | ||
process.stderr.write('stderr', function() { | ||
process.exit(42); | ||
}); | ||
} catch (e) { | ||
process.exit(84); | ||
} | ||
}); | ||
}); | ||
} catch (e) { | ||
assert.strictEqual(e.code, 'EBADF'); | ||
assert.strictEqual(e.message, 'EBADF: bad file descriptor, write'); | ||
process.exit(126); | ||
} | ||
return; | ||
} | ||
|
||
// Run the script in a shell but close stdout and stderr. | ||
var cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`; | ||
var proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); | ||
const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`; | ||
const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); | ||
|
||
proc.on('exit', common.mustCall(function(exitCode) { | ||
assert.equal(exitCode, 42); | ||
assert.strictEqual(exitCode, common.isAix ? 126 : 42); | ||
})); |