summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDave O'Mahony <david.c.omahony@gmail.com>2018-03-17 16:16:31 -0230
committerTrivikram Kamat <16024985+trivikr@users.noreply.github.com>2018-04-06 23:26:07 -0700
commit3217c707185a0918818a14f5f9ddf400d5590c7d (patch)
tree2513dc83f708e4aefb336cc87e8a9777921085ba /test
parentc60c93cba27626680061109766cbc2e102dd38a8 (diff)
downloadandroid-node-v8-3217c707185a0918818a14f5f9ddf400d5590c7d.tar.gz
android-node-v8-3217c707185a0918818a14f5f9ddf400d5590c7d.tar.bz2
android-node-v8-3217c707185a0918818a14f5f9ddf400d5590c7d.zip
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>
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/readfile_pipe_test.txt5
-rw-r--r--test/parallel/test-fs-readfile-pipe.js19
2 files changed, 19 insertions, 5 deletions
diff --git a/test/fixtures/readfile_pipe_test.txt b/test/fixtures/readfile_pipe_test.txt
new file mode 100644
index 0000000000..65975655dc
--- /dev/null
+++ b/test/fixtures/readfile_pipe_test.txt
@@ -0,0 +1,5 @@
+xxxx xxxx xxxx xxxx
+xxxx xxxx xxxx xxxx
+xxxx xxxx xxxx xxxx
+xxxx xxxx xxxx xxxx
+xxxx xxxx xxxx xxxx
diff --git a/test/parallel/test-fs-readfile-pipe.js b/test/parallel/test-fs-readfile-pipe.js
index 0c26d7c287..c9f7144c11 100644
--- a/test/parallel/test-fs-readfile-pipe.js
+++ b/test/parallel/test-fs-readfile-pipe.js
@@ -30,8 +30,6 @@ if (common.isWindows || common.isAIX)
const assert = require('assert');
const fs = require('fs');
-const dataExpected = fs.readFileSync(__filename, 'utf8');
-
if (process.argv[2] === 'child') {
fs.readFile('/dev/stdin', function(er, data) {
assert.ifError(er);
@@ -40,13 +38,24 @@ if (process.argv[2] === 'child') {
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 f = JSON.stringify(__filename);
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) {
assert.ifError(err);
- assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
- assert.strictEqual(stderr, '', 'it does not write to stderr');
+ assert.strictEqual(
+ 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');
});