Skip to content

Commit

Permalink
test: update test-stdout-to-file
Browse files Browse the repository at this point in the history
* 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: #9939
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
scalkpdev authored and MylesBorins committed Dec 20, 2016
1 parent 63f571e commit e371233
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/parallel/test-stdout-to-file.js
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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();
});
}));
}

var finished = false;
Expand Down

0 comments on commit e371233

Please sign in to comment.