Browse Source

test: update test-stdout-to-file

* changed vars to const
* changed assert.equal to assert.strictEqual
* added a common.mustCall in the childProcess.exec callback
* replaced 2 console.log strings with template strings for readability
* had to break up line 9 because it was causing a line max length (80)
listing err

PR-URL: https://github.com/nodejs/node/pull/9939
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
scalkpdev 8 years ago
committed by Anna Henningsen
parent
commit
626d59f7a6
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 27
      test/parallel/test-stdout-to-file.js

27
test/parallel/test-stdout-to-file.js

@ -1,13 +1,14 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var childProcess = require('child_process');
var fs = require('fs');
const common = require('../common');
const assert = require('assert');
const path = require('path');
const childProcess = require('child_process');
const fs = require('fs');
var scriptString = path.join(common.fixturesDir, 'print-chars.js');
var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js');
var tmpFile = path.join(common.tmpDir, 'stdout.txt');
const scriptString = path.join(common.fixturesDir, 'print-chars.js');
const scriptBuffer = path.join(common.fixturesDir,
'print-chars-from-buffer.js');
const tmpFile = path.join(common.tmpDir, 'stdout.txt');
common.refreshTmpDir();
@ -24,22 +25,22 @@ function test(size, useBuffer, cb) {
fs.unlinkSync(tmpFile);
} catch (e) {}
console.log(size + ' chars to ' + tmpFile + '...');
console.log(`${size} chars to ${tmpFile}...`);
childProcess.exec(cmd, function(err) {
childProcess.exec(cmd, common.mustCall(function(err) {
if (err) throw err;
console.log('done!');
var stat = fs.statSync(tmpFile);
console.log(tmpFile + ' has ' + stat.size + ' bytes');
console.log(`${tmpFile} has ${stat.size} bytes`);
assert.equal(size, stat.size);
assert.strictEqual(size, stat.size);
fs.unlinkSync(tmpFile);
cb();
});
}));
}
test(1024 * 1024, false, common.mustCall(function() {

Loading…
Cancel
Save