test: update assert messages to show expected and actual values
uses the same approach as in test-fs-readfile-pipe-large PR-URL: https://github.com/nodejs/node/pull/19420 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
c60c93cba2
commit
3217c70718
5
test/fixtures/readfile_pipe_test.txt
vendored
Normal file
5
test/fixtures/readfile_pipe_test.txt
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
xxxx xxxx xxxx xxxx
|
||||||
|
xxxx xxxx xxxx xxxx
|
||||||
|
xxxx xxxx xxxx xxxx
|
||||||
|
xxxx xxxx xxxx xxxx
|
||||||
|
xxxx xxxx xxxx xxxx
|
@ -30,8 +30,6 @@ if (common.isWindows || common.isAIX)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const dataExpected = fs.readFileSync(__filename, 'utf8');
|
|
||||||
|
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
fs.readFile('/dev/stdin', function(er, data) {
|
fs.readFile('/dev/stdin', function(er, data) {
|
||||||
assert.ifError(er);
|
assert.ifError(er);
|
||||||
@ -40,13 +38,24 @@ if (process.argv[2] === 'child') {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
const filename = fixtures.path('readfile_pipe_test.txt');
|
||||||
|
const dataExpected = fs.readFileSync(filename).toString();
|
||||||
|
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const f = JSON.stringify(__filename);
|
const f = JSON.stringify(__filename);
|
||||||
const node = JSON.stringify(process.execPath);
|
const node = JSON.stringify(process.execPath);
|
||||||
const cmd = `cat ${f} | ${node} ${f} child`;
|
const cmd = `cat ${filename} | ${node} ${f} child`;
|
||||||
exec(cmd, function(err, stdout, stderr) {
|
exec(cmd, function(err, stdout, stderr) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
|
assert.strictEqual(
|
||||||
assert.strictEqual(stderr, '', 'it does not write to stderr');
|
stdout,
|
||||||
|
dataExpected,
|
||||||
|
`expected to read: '${dataExpected}' but got: '${stdout}'`);
|
||||||
|
assert.strictEqual(
|
||||||
|
stderr,
|
||||||
|
'',
|
||||||
|
`expected not to read anything from stderr but got: '${stderr}'`);
|
||||||
console.log('ok');
|
console.log('ok');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user