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>
v4.x
scalkpdev 8 years ago
committed by Myles Borins
parent
commit
e3712334a3
  1. 27
      test/parallel/test-stdout-to-file.js

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

@ -1,13 +1,14 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var path = require('path'); const path = require('path');
var childProcess = require('child_process'); const childProcess = require('child_process');
var fs = require('fs'); const fs = require('fs');
var scriptString = path.join(common.fixturesDir, 'print-chars.js'); const scriptString = path.join(common.fixturesDir, 'print-chars.js');
var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js'); const scriptBuffer = path.join(common.fixturesDir,
var tmpFile = path.join(common.tmpDir, 'stdout.txt'); 'print-chars-from-buffer.js');
const tmpFile = path.join(common.tmpDir, 'stdout.txt');
common.refreshTmpDir(); common.refreshTmpDir();
@ -24,22 +25,22 @@ function test(size, useBuffer, cb) {
fs.unlinkSync(tmpFile); fs.unlinkSync(tmpFile);
} catch (e) {} } 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; if (err) throw err;
console.log('done!'); console.log('done!');
var stat = fs.statSync(tmpFile); 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); fs.unlinkSync(tmpFile);
cb(); cb();
}); }));
} }
var finished = false; var finished = false;

Loading…
Cancel
Save