Browse Source

test: modernize syntax, add strict checks

Changed `var` to `const`, strings to template literals, and
assert.equal to assert.strictEqual where appropriate.

PR-URL: https://github.com/nodejs/node/pull/8841
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
v6.x
Lydia Kats 8 years ago
committed by Jeremiah Senkpiel
parent
commit
fc42825530
  1. 20
      test/parallel/test-fs-readfile-pipe-large.js
  2. 16
      test/parallel/test-fs-readfile-pipe.js
  3. 20
      test/parallel/test-fs-readfilesync-pipe-large.js

20
test/parallel/test-fs-readfile-pipe-large.js

@ -1,7 +1,7 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
const common = require('../common');
const assert = require('assert');
const path = require('path');
// simulate `cat readfile.js | node readfile.js`
@ -10,7 +10,7 @@ if (common.isWindows || common.isAix) {
return;
}
var fs = require('fs');
const fs = require('fs');
if (process.argv[2] === 'child') {
fs.readFile('/dev/stdin', function(er, data) {
@ -20,15 +20,15 @@ if (process.argv[2] === 'child') {
return;
}
var filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt');
var dataExpected = new Array(1000000).join('a');
const filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt');
const dataExpected = new Array(1000000).join('a');
common.refreshTmpDir();
fs.writeFileSync(filename, dataExpected);
var exec = require('child_process').exec;
var f = JSON.stringify(__filename);
var node = JSON.stringify(process.execPath);
var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child';
const exec = require('child_process').exec;
const f = JSON.stringify(__filename);
const node = JSON.stringify(process.execPath);
const cmd = `cat ${filename} | ${node} ${f} child`;
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');

16
test/parallel/test-fs-readfile-pipe.js

@ -1,6 +1,6 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');
// simulate `cat readfile.js | node readfile.js`
@ -9,9 +9,9 @@ if (common.isWindows || common.isAix) {
return;
}
var fs = require('fs');
const fs = require('fs');
var dataExpected = fs.readFileSync(__filename, 'utf8');
const dataExpected = fs.readFileSync(__filename, 'utf8');
if (process.argv[2] === 'child') {
fs.readFile('/dev/stdin', function(er, data) {
@ -21,10 +21,10 @@ if (process.argv[2] === 'child') {
return;
}
var exec = require('child_process').exec;
var f = JSON.stringify(__filename);
var node = JSON.stringify(process.execPath);
var cmd = 'cat ' + f + ' | ' + node + ' ' + f + ' child';
const exec = require('child_process').exec;
const f = JSON.stringify(__filename);
const node = JSON.stringify(process.execPath);
const cmd = `cat ${f} | ${node} ${f} child`;
exec(cmd, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');

20
test/parallel/test-fs-readfilesync-pipe-large.js

@ -1,7 +1,7 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
const common = require('../common');
const assert = require('assert');
const path = require('path');
// simulate `cat readfile.js | node readfile.js`
@ -10,22 +10,22 @@ if (common.isWindows || common.isAix) {
return;
}
var fs = require('fs');
const fs = require('fs');
if (process.argv[2] === 'child') {
process.stdout.write(fs.readFileSync('/dev/stdin', 'utf8'));
return;
}
var filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt');
var dataExpected = new Array(1000000).join('a');
const filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt');
const dataExpected = new Array(1000000).join('a');
common.refreshTmpDir();
fs.writeFileSync(filename, dataExpected);
var exec = require('child_process').exec;
var f = JSON.stringify(__filename);
var node = JSON.stringify(process.execPath);
var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child';
const exec = require('child_process').exec;
const f = JSON.stringify(__filename);
const node = JSON.stringify(process.execPath);
const cmd = `cat ${filename} | ${node} ${f} child`;
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');

Loading…
Cancel
Save