Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: complete coverage of lib/child_process.js #12367

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion test/parallel/test-child-process-execfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const execFile = require('child_process').execFile;
const path = require('path');
const uv = process.binding('uv');

const fixture = path.join(common.fixturesDir, 'exit.js');

Expand All @@ -19,3 +19,22 @@ const fixture = path.join(common.fixturesDir, 'exit.js');
})
);
}

{
// Verify that negative exit codes can be translated to UV error names.
const errorString = `Error: Command failed: ${process.execPath}`;
const code = -1;
const callback = common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err.toString().trim(), errorString);
assert.strictEqual(err.code, uv.errname(code));
assert.strictEqual(err.killed, true);
assert.strictEqual(err.signal, null);
assert.strictEqual(err.cmd, process.execPath);
assert.strictEqual(stdout.trim(), '');
assert.strictEqual(stderr.trim(), '');
});
const child = execFile(process.execPath, callback);

child.kill();
child.emit('close', code, null);
}