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: improve test-child-process-exec-buffer #10275

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 12 additions & 10 deletions test/parallel/test-child-process-exec-buffer.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var os = require('os');
var str = 'hello';
const assert = require('assert');
const exec = require('child_process').exec;
const os = require('os');
const str = 'hello';

// default encoding
exec('echo ' + str, common.mustCall(function(err, stdout, stderr) {
assert.ok('string', typeof stdout, 'Expected stdout to be a string');
assert.ok('string', typeof stderr, 'Expected stderr to be a string');
assert.equal(str + os.EOL, stdout);
assert.strictEqual(typeof stdout, 'string', 'Expected stdout to be a string');
assert.strictEqual(typeof stderr, 'string', 'Expected stderr to be a string');
assert.strictEqual(str + os.EOL, stdout);
}));

// no encoding (Buffers expected)
exec('echo ' + str, {
encoding: null
}, common.mustCall(function(err, stdout, stderr) {
assert.ok(stdout instanceof Buffer, 'Expected stdout to be a Buffer');
assert.ok(stderr instanceof Buffer, 'Expected stderr to be a Buffer');
assert.equal(str + os.EOL, stdout.toString());
assert.strictEqual(stdout instanceof Buffer, true,
'Expected stdout to be a Buffer');
assert.strictEqual(stderr instanceof Buffer, true,
'Expected stderr to be a Buffer');
assert.strictEqual(str + os.EOL, stdout.toString());
}));