Browse Source

test: reduce string concatenations

PR-URL: https://github.com/nodejs/node/pull/12735
Refs: https://github.com/nodejs/node/pull/12455
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
v6
Vse Mozhet Byt 8 years ago
parent
commit
8b76c3e60c
  1. 2
      test/addons/repl-domain-abort/test.js
  2. 20
      test/common/index.js
  3. 16
      test/debugger/helper-debugger-repl.js
  4. 2
      test/debugger/test-debugger-repl-utf8.js
  5. 2
      test/gc/test-http-client-connaborted.js
  6. 2
      test/gc/test-http-client-onerror.js
  7. 2
      test/gc/test-http-client-timeout.js
  8. 2
      test/gc/test-http-client.js
  9. 2
      test/gc/test-net-timeout.js
  10. 22
      test/inspector/inspector-helper.js
  11. 6
      test/inspector/test-inspector.js
  12. 2
      test/internet/test-dns-cares-domains.js
  13. 2
      test/internet/test-dns-ipv6.js
  14. 2
      test/internet/test-dns.js
  15. 2
      test/internet/test-tls-add-ca-cert.js
  16. 2
      test/known_issues/test-cwd-enoent-file.js
  17. 2
      test/parallel/test-assert.js
  18. 4
      test/parallel/test-async-wrap-check-providers.js
  19. 2
      test/parallel/test-buffer-badhex.js
  20. 2
      test/parallel/test-buffer-includes.js
  21. 2
      test/parallel/test-buffer-indexof.js
  22. 4
      test/parallel/test-child-process-buffering.js
  23. 2
      test/parallel/test-child-process-default-options.js
  24. 4
      test/parallel/test-child-process-double-pipe.js
  25. 2
      test/parallel/test-child-process-env.js
  26. 6
      test/parallel/test-child-process-exec-env.js
  27. 2
      test/parallel/test-child-process-fork-close.js
  28. 2
      test/parallel/test-child-process-fork.js
  29. 2
      test/parallel/test-child-process-fork3.js
  30. 4
      test/parallel/test-child-process-internal.js
  31. 4
      test/parallel/test-child-process-ipc.js
  32. 2
      test/parallel/test-child-process-set-blocking.js
  33. 2
      test/parallel/test-child-process-spawn-error.js
  34. 2
      test/parallel/test-child-process-spawn-typeerror.js
  35. 8
      test/parallel/test-child-process-spawnsync-input.js
  36. 2
      test/parallel/test-child-process-spawnsync-maxbuf.js
  37. 2
      test/parallel/test-child-process-stdin.js
  38. 6
      test/parallel/test-cli-eval.js
  39. 7
      test/parallel/test-cli-node-options.js
  40. 12
      test/parallel/test-cli-syntax.js
  41. 4
      test/parallel/test-cluster-bind-twice.js
  42. 2
      test/parallel/test-cluster-eaccess.js
  43. 4
      test/parallel/test-cluster-eaddrinuse.js
  44. 7
      test/parallel/test-cluster-message.js
  45. 7
      test/parallel/test-cluster-worker-exit.js
  46. 7
      test/parallel/test-cluster-worker-kill.js
  47. 8
      test/parallel/test-console.js
  48. 2
      test/parallel/test-crypto-authenticated.js
  49. 27
      test/parallel/test-crypto-binary-default.js
  50. 6
      test/parallel/test-crypto-certificate.js
  51. 11
      test/parallel/test-crypto-fips.js
  52. 28
      test/parallel/test-crypto-rsa-dsa.js
  53. 12
      test/parallel/test-crypto-sign-verify.js
  54. 6
      test/parallel/test-crypto-verify-failure.js
  55. 12
      test/parallel/test-crypto.js
  56. 2
      test/parallel/test-cwd-enoent-preload.js
  57. 2
      test/parallel/test-cwd-enoent-repl.js
  58. 2
      test/parallel/test-cwd-enoent.js
  59. 4
      test/parallel/test-dgram-bind-shared-ports.js
  60. 2
      test/parallel/test-dgram-error-message-address.js
  61. 10
      test/parallel/test-domain-enter-exit.js
  62. 9
      test/parallel/test-domain-uncaught-exception.js
  63. 10
      test/parallel/test-domain-with-abort-on-uncaught-exception.js
  64. 4
      test/parallel/test-domain.js
  65. 4
      test/parallel/test-dsa-fips-invalid-key.js
  66. 3
      test/parallel/test-error-reporting.js
  67. 2
      test/parallel/test-eval.js
  68. 2
      test/parallel/test-exception-handler2.js
  69. 8
      test/parallel/test-file-write-stream2.js
  70. 6
      test/parallel/test-file-write-stream3.js
  71. 2
      test/parallel/test-fs-append-file-sync.js
  72. 2
      test/parallel/test-fs-append-file.js
  73. 2
      test/parallel/test-fs-buffertype-writesync.js
  74. 7
      test/parallel/test-fs-error-messages.js
  75. 4
      test/parallel/test-fs-exists.js
  76. 6
      test/parallel/test-fs-mkdir.js
  77. 5
      test/parallel/test-fs-non-number-arguments-throw.js
  78. 2
      test/parallel/test-fs-readdir.js
  79. 4
      test/parallel/test-fs-readfile-error.js
  80. 86
      test/parallel/test-fs-realpath.js
  81. 2
      test/parallel/test-fs-sir-writes-alot.js
  82. 14
      test/parallel/test-fs-stat.js
  83. 6
      test/parallel/test-fs-stream-double-close.js
  84. 4
      test/parallel/test-fs-symlink-dir-junction-relative.js
  85. 4
      test/parallel/test-fs-symlink-dir-junction.js
  86. 2
      test/parallel/test-fs-timestamp-parsing-error.js
  87. 2
      test/parallel/test-fs-truncate-GH-6233.js
  88. 2
      test/parallel/test-fs-write-file.js
  89. 2
      test/parallel/test-fs-write-stream-err.js
  90. 2
      test/parallel/test-fs-write-string-coerce.js
  91. 4
      test/parallel/test-http-abort-client.js
  92. 4
      test/parallel/test-http-abort-queued.js
  93. 4
      test/parallel/test-http-after-connect.js
  94. 2
      test/parallel/test-http-agent-error-on-idle.js
  95. 2
      test/parallel/test-http-agent-getname.js
  96. 2
      test/parallel/test-http-agent-maxsockets.js
  97. 2
      test/parallel/test-http-buffer-sanity.js
  98. 2
      test/parallel/test-http-chunk-problem.js
  99. 8
      test/parallel/test-http-client-abort.js
  100. 2
      test/parallel/test-http-client-agent.js

2
test/addons/repl-domain-abort/test.js

@ -39,7 +39,7 @@ process.on('exit', function() {
const lines = [
// This line shouldn't cause an assertion error.
'require(\'' + buildPath + '\')' +
`require('${buildPath}')` +
// Log output to double check callback ran.
'.method(function() { console.log(\'cb_ran\'); });',
];

20
test/common/index.js

@ -55,9 +55,8 @@ exports.isLinux = process.platform === 'linux';
exports.isOSX = process.platform === 'darwin';
exports.enoughTestMem = os.totalmem() > 0x40000000; /* 1 Gb */
exports.bufferMaxSizeMsg = new RegExp('^RangeError: "size" argument' +
' must not be larger than ' +
buffer.kMaxLength + '$');
exports.bufferMaxSizeMsg = new RegExp(
`^RangeError: "size" argument must not be larger than ${buffer.kMaxLength}$`);
const cpus = os.cpus();
exports.enoughTestCpu = Array.isArray(cpus) &&
(cpus.length > 1 || cpus[0].speed > 999);
@ -118,7 +117,7 @@ exports.refreshTmpDir = function() {
if (process.env.TEST_THREAD_ID) {
exports.PORT += process.env.TEST_THREAD_ID * 100;
exports.tmpDirName += '.' + process.env.TEST_THREAD_ID;
exports.tmpDirName += `.${process.env.TEST_THREAD_ID}`;
}
exports.tmpDir = path.join(testRoot, exports.tmpDirName);
@ -217,10 +216,10 @@ Object.defineProperty(exports, 'hasFipsCrypto', {
if (exports.isWindows) {
exports.PIPE = '\\\\.\\pipe\\libuv-test';
if (process.env.TEST_THREAD_ID) {
exports.PIPE += '.' + process.env.TEST_THREAD_ID;
exports.PIPE += `.${process.env.TEST_THREAD_ID}`;
}
} else {
exports.PIPE = exports.tmpDir + '/test.sock';
exports.PIPE = `${exports.tmpDir}/test.sock`;
}
const ifaces = os.networkInterfaces();
@ -256,10 +255,9 @@ exports.childShouldThrowAndAbort = function() {
exports.ddCommand = function(filename, kilobytes) {
if (exports.isWindows) {
const p = path.resolve(exports.fixturesDir, 'create-file.js');
return '"' + process.argv[0] + '" "' + p + '" "' +
filename + '" ' + (kilobytes * 1024);
return `"${process.argv[0]}" "${p}" "${filename}" ${kilobytes * 1024}`;
} else {
return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes;
return `dd if=/dev/zero of="${filename}" bs=1024 count=${kilobytes}`;
}
};
@ -495,7 +493,7 @@ exports.canCreateSymLink = function() {
let output = '';
try {
output = execSync(whoamiPath + ' /priv', { timout: 1000 });
output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
} catch (e) {
err = true;
} finally {
@ -522,7 +520,7 @@ exports.skip = function(msg) {
function ArrayStream() {
this.run = function(data) {
data.forEach((line) => {
this.emit('data', line + '\n');
this.emit('data', `${line}\n`);
});
};
}

16
test/debugger/helper-debugger-repl.js

@ -34,11 +34,11 @@ let quit;
function startDebugger(scriptToDebug) {
scriptToDebug = process.env.NODE_DEBUGGER_TEST_SCRIPT ||
common.fixturesDir + '/' + scriptToDebug;
`${common.fixturesDir}/${scriptToDebug}`;
child = spawn(process.execPath, ['debug', '--port=' + port, scriptToDebug]);
child = spawn(process.execPath, ['debug', `--port=${port}`, scriptToDebug]);
console.error('./node', 'debug', '--port=' + port, scriptToDebug);
console.error('./node', 'debug', `--port=${port}`, scriptToDebug);
child.stdout.setEncoding('utf-8');
child.stdout.on('data', function(data) {
@ -53,10 +53,10 @@ function startDebugger(scriptToDebug) {
child.on('line', function(line) {
line = line.replace(/^(debug> *)+/, '');
console.log(line);
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
assert.ok(expected.length > 0, `Got unexpected line: ${line}`);
const expectedLine = expected[0].lines.shift();
assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine);
assert.ok(line.match(expectedLine) !== null, `${line} != ${expectedLine}`);
if (expected[0].lines.length === 0) {
const callback = expected[0].callback;
@ -83,7 +83,7 @@ function startDebugger(scriptToDebug) {
console.error('dying badly buffer=%j', buffer);
let err = 'Timeout';
if (expected.length > 0 && expected[0].lines) {
err = err + '. Expected: ' + expected[0].lines.shift();
err = `${err}. Expected: ${expected[0].lines.shift()}`;
}
child.on('close', function() {
@ -112,8 +112,8 @@ function startDebugger(scriptToDebug) {
function addTest(input, output) {
function next() {
if (expected.length > 0) {
console.log('debug> ' + expected[0].input);
child.stdin.write(expected[0].input + '\n');
console.log(`debug> ${expected[0].input}`);
child.stdin.write(`${expected[0].input}\n`);
if (!expected[0].lines) {
const callback = expected[0].callback;

2
test/debugger/test-debugger-repl-utf8.js

@ -21,7 +21,7 @@
'use strict';
const common = require('../common');
const script = common.fixturesDir + '/breakpoints_utf8.js';
const script = `${common.fixturesDir}/breakpoints_utf8.js`;
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
require('./test-debugger-repl.js');

2
test/gc/test-http-client-connaborted.js

@ -15,7 +15,7 @@ let done = 0;
let count = 0;
let countGC = 0;
console.log('We should do ' + todo + ' requests');
console.log(`We should do ${todo} requests`);
const server = http.createServer(serverHandler);
server.listen(0, getall);

2
test/gc/test-http-client-onerror.js

@ -17,7 +17,7 @@ let done = 0;
let count = 0;
let countGC = 0;
console.log('We should do ' + todo + ' requests');
console.log(`We should do ${todo} requests`);
const server = http.createServer(serverHandler);
server.listen(0, runTest);

2
test/gc/test-http-client-timeout.js

@ -19,7 +19,7 @@ let done = 0;
let count = 0;
let countGC = 0;
console.log('We should do ' + todo + ' requests');
console.log(`We should do ${todo} requests`);
const server = http.createServer(serverHandler);
server.listen(0, getall);

2
test/gc/test-http-client.js

@ -15,7 +15,7 @@ let done = 0;
let count = 0;
let countGC = 0;
console.log('We should do ' + todo + ' requests');
console.log(`We should do ${todo} requests`);
const server = http.createServer(serverHandler);
server.listen(0, getall);

2
test/gc/test-net-timeout.js

@ -26,7 +26,7 @@ let done = 0;
let count = 0;
let countGC = 0;
console.log('We should do ' + todo + ' requests');
console.log(`We should do ${todo} requests`);
const server = net.createServer(serverHandler);
server.listen(0, getall);

22
test/inspector/inspector-helper.js

@ -169,13 +169,15 @@ TestSession.prototype.processMessage_ = function(message) {
assert.strictEqual(id, this.expectedId_);
this.expectedId_++;
if (this.responseCheckers_[id]) {
assert(message['result'], JSON.stringify(message) + ' (response to ' +
JSON.stringify(this.messages_[id]) + ')');
const messageJSON = JSON.stringify(message);
const idJSON = JSON.stringify(this.messages_[id]);
assert(message['result'], `${messageJSON} (response to ${idJSON})`);
this.responseCheckers_[id](message['result']);
delete this.responseCheckers_[id];
}
assert(!message['error'], JSON.stringify(message) + ' (replying to ' +
JSON.stringify(this.messages_[id]) + ')');
const messageJSON = JSON.stringify(message);
const idJSON = JSON.stringify(this.messages_[id]);
assert(!message['error'], `${messageJSON} (replying to ${idJSON})`);
delete this.messages_[id];
if (id === this.lastId_) {
this.lastMessageResponseCallback_ && this.lastMessageResponseCallback_();
@ -213,12 +215,8 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
};
this.sendAll_(commands, () => {
timeoutId = setTimeout(() => {
let s = '';
for (const id in this.messages_) {
s += id + ', ';
}
assert.fail('Messages without response: ' +
s.substring(0, s.length - 2));
assert.fail(`Messages without response: ${
Object.keys(this.messages_).join(', ')}`);
}, TIMEOUT);
});
});
@ -241,7 +239,7 @@ TestSession.prototype.expectMessages = function(expects) {
if (!(expects instanceof Array)) expects = [ expects ];
const callback = this.createCallbackWithTimeout_(
'Matching response was not received:\n' + expects[0]);
`Matching response was not received:\n${expects[0]}`);
this.messagefilter_ = (message) => {
if (expects[0](message))
expects.shift();
@ -256,7 +254,7 @@ TestSession.prototype.expectMessages = function(expects) {
TestSession.prototype.expectStderrOutput = function(regexp) {
this.harness_.addStderrFilter(
regexp,
this.createCallbackWithTimeout_('Timed out waiting for ' + regexp));
this.createCallbackWithTimeout_(`Timed out waiting for ${regexp}`));
return this;
};

6
test/inspector/test-inspector.js

@ -19,7 +19,7 @@ function checkVersion(err, response) {
assert.ifError(err);
assert.ok(response);
const expected = {
'Browser': 'node.js/' + process.version,
'Browser': `node.js/${process.version}`,
'Protocol-Version': '1.1',
};
assert.strictEqual(JSON.stringify(response),
@ -36,7 +36,7 @@ function expectMainScriptSource(result) {
const expected = helper.mainScriptSource();
const source = result['scriptSource'];
assert(source && (source.includes(expected)),
'Script source is wrong: ' + source);
`Script source is wrong: ${source}`);
}
function setupExpectBreakOnLine(line, url, session, scopeIdCallback) {
@ -187,7 +187,7 @@ function testI18NCharacters(session) {
{
'method': 'Debugger.evaluateOnCallFrame', 'params': {
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
'expression': 'console.log("' + chars + '")',
'expression': `console.log("${chars}")`,
'objectGroup': 'console',
'includeCommandLineAPI': true,
'silent': false,

2
test/internet/test-dns-cares-domains.js

@ -21,7 +21,7 @@ methods.forEach(function(method) {
const d = domain.create();
d.run(function() {
dns[method]('google.com', function() {
assert.strictEqual(process.domain, d, method + ' retains domain');
assert.strictEqual(process.domain, d, `${method} retains domain`);
});
});
});

2
test/internet/test-dns-ipv6.js

@ -164,7 +164,7 @@ TEST(function test_lookup_all_ipv6(done) {
ips.forEach((ip) => {
assert.ok(isIPv6(ip.address),
'Invalid IPv6: ' + ip.address.toString());
`Invalid IPv6: ${ip.address.toString()}`);
assert.strictEqual(ip.family, 6);
});

2
test/internet/test-dns.js

@ -545,7 +545,7 @@ req.oncomplete = function(err, domains) {
};
process.on('exit', function() {
console.log(completed + ' tests completed');
console.log(`${completed} tests completed`);
assert.strictEqual(running, false);
assert.strictEqual(expected, completed);
assert.ok(getaddrinfoCallbackCalled);

2
test/internet/test-tls-add-ca-cert.js

@ -13,7 +13,7 @@ const fs = require('fs');
const tls = require('tls');
function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', n + '.pem');
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
}
function loadPEM(n) {

2
test/known_issues/test-cwd-enoent-file.js

@ -19,7 +19,7 @@ if (process.argv[2] === 'child') {
// Do nothing.
} else {
common.refreshTmpDir();
const dir = fs.mkdtempSync(common.tmpDir + '/');
const dir = fs.mkdtempSync(`${common.tmpDir}/`);
process.chdir(dir);
fs.rmdirSync(dir);
assert.throws(process.cwd,

2
test/parallel/test-assert.js

@ -177,7 +177,7 @@ assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2));
// having an identical prototype property
const nbRoot = {
toString: function() { return this.first + ' ' + this.last; }
toString: function() { return `${this.first} ${this.last}`; }
};
function nameBuilder(first, last) {

4
test/parallel/test-async-wrap-check-providers.js

@ -94,8 +94,8 @@ process.on('SIGINT', () => process.exit());
// Run from closed net server above.
function checkTLS() {
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem')
key: fs.readFileSync(`${common.fixturesDir}/keys/ec-key.pem`),
cert: fs.readFileSync(`${common.fixturesDir}/keys/ec-cert.pem`)
};
const server = tls.createServer(options, common.noop)
.listen(0, function() {

2
test/parallel/test-buffer-badhex.js

@ -44,6 +44,6 @@ const Buffer = require('buffer').Buffer;
const hex = buf.toString('hex');
assert.deepStrictEqual(Buffer.from(hex, 'hex'), buf);
const badHex = hex.slice(0, 256) + 'xx' + hex.slice(256, 510);
const badHex = `${hex.slice(0, 256)}xx${hex.slice(256, 510)}`;
assert.deepStrictEqual(Buffer.from(badHex, 'hex'), buf.slice(0, 128));
}

2
test/parallel/test-buffer-includes.js

@ -199,7 +199,7 @@ const longBufferString = Buffer.from(longString);
let pattern = 'ABACABADABACABA';
for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
const includes = longBufferString.includes(pattern, i);
assert(includes, 'Long ABACABA...-string at index ' + i);
assert(includes, `Long ABACABA...-string at index ${i}`);
}
assert(longBufferString.includes('AJABACA'), 'Long AJABACA, First J');
assert(longBufferString.includes('AJABACA', 511), 'Long AJABACA, Second J');

2
test/parallel/test-buffer-indexof.js

@ -255,7 +255,7 @@ let pattern = 'ABACABADABACABA';
for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
const index = longBufferString.indexOf(pattern, i);
assert.strictEqual((i + 15) & ~0xf, index,
'Long ABACABA...-string at index ' + i);
`Long ABACABA...-string at index ${i}`);
}
assert.strictEqual(510, longBufferString.indexOf('AJABACA'),
'Long AJABACA, First J');

4
test/parallel/test-child-process-buffering.js

@ -29,12 +29,12 @@ function pwd(callback) {
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(s) {
console.log('stdout: ' + JSON.stringify(s));
console.log(`stdout: ${JSON.stringify(s)}`);
output += s;
});
child.on('exit', common.mustCall(function(c) {
console.log('exit: ' + c);
console.log(`exit: ${c}`);
assert.strictEqual(0, c);
}));

2
test/parallel/test-child-process-default-options.js

@ -39,7 +39,7 @@ let response = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
console.log(`stdout: ${chunk}`);
response += chunk;
});

4
test/parallel/test-child-process-double-pipe.js

@ -56,7 +56,7 @@ if (common.isWindows) {
// pipe echo | grep
echo.stdout.on('data', function(data) {
console.error('grep stdin write ' + data.length);
console.error(`grep stdin write ${data.length}`);
if (!grep.stdin.write(data)) {
echo.stdout.pause();
}
@ -86,7 +86,7 @@ sed.on('exit', function() {
// pipe grep | sed
grep.stdout.on('data', function(data) {
console.error('grep stdout ' + data.length);
console.error(`grep stdout ${data.length}`);
if (!sed.stdin.write(data)) {
grep.stdout.pause();
}

2
test/parallel/test-child-process-env.js

@ -45,7 +45,7 @@ let response = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
console.log(`stdout: ${chunk}`);
response += chunk;
});

6
test/parallel/test-child-process-exec-env.js

@ -31,9 +31,9 @@ let child;
function after(err, stdout, stderr) {
if (err) {
error_count++;
console.log('error!: ' + err.code);
console.log('stdout: ' + JSON.stringify(stdout));
console.log('stderr: ' + JSON.stringify(stderr));
console.log(`error!: ${err.code}`);
console.log(`stdout: ${JSON.stringify(stdout)}`);
console.log(`stderr: ${JSON.stringify(stderr)}`);
assert.strictEqual(false, err.killed);
} else {
success_count++;

2
test/parallel/test-child-process-fork-close.js

@ -24,7 +24,7 @@ const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
const cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');
const cp = fork(`${common.fixturesDir}/child-process-message-and-exit.js`);
let gotMessage = false;
let gotExit = false;

2
test/parallel/test-child-process-fork.js

@ -25,7 +25,7 @@ const assert = require('assert');
const fork = require('child_process').fork;
const args = ['foo', 'bar'];
const n = fork(common.fixturesDir + '/child-process-spawn-node.js', args);
const n = fork(`${common.fixturesDir}/child-process-spawn-node.js`, args);
assert.strictEqual(n.channel, n._channel);
assert.deepStrictEqual(args, ['foo', 'bar']);

2
test/parallel/test-child-process-fork3.js

@ -23,4 +23,4 @@
const common = require('../common');
const child_process = require('child_process');
child_process.fork(common.fixturesDir + '/empty.js'); // should not hang
child_process.fork(`${common.fixturesDir}/empty.js`); // should not hang

4
test/parallel/test-child-process-internal.js

@ -25,8 +25,8 @@ const assert = require('assert');
//messages
const PREFIX = 'NODE_';
const normal = {cmd: 'foo' + PREFIX};
const internal = {cmd: PREFIX + 'bar'};
const normal = {cmd: `foo${PREFIX}`};
const internal = {cmd: `${PREFIX}bar`};
if (process.argv[2] === 'child') {
//send non-internal message containing PREFIX at a non prefix position

4
test/parallel/test-child-process-ipc.js

@ -36,13 +36,13 @@ let gotEcho = false;
const child = spawn(process.argv[0], [sub]);
child.stderr.on('data', function(data) {
console.log('parent stderr: ' + data);
console.log(`parent stderr: ${data}`);
});
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(data) {
console.log('child said: ' + JSON.stringify(data));
console.log(`child said: ${JSON.stringify(data)}`);
if (!gotHelloWorld) {
console.error('testing for hello world');
assert.strictEqual('hello world\r\n', data);

2
test/parallel/test-child-process-set-blocking.js

@ -26,7 +26,7 @@ const ch = require('child_process');
const SIZE = 100000;
const cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
const cp = ch.spawn('python', ['-c', `print ${SIZE} * "C"`], {
stdio: 'inherit'
});

2
test/parallel/test-child-process-spawn-error.js

@ -32,7 +32,7 @@ const enoentChild = spawn(enoentPath, spawnargs);
enoentChild.on('error', common.mustCall(function(err) {
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.errno, 'ENOENT');
assert.strictEqual(err.syscall, 'spawn ' + enoentPath);
assert.strictEqual(err.syscall, `spawn ${enoentPath}`);
assert.strictEqual(err.path, enoentPath);
assert.deepStrictEqual(err.spawnargs, spawnargs);
}));

2
test/parallel/test-child-process-spawn-typeerror.js

@ -32,7 +32,7 @@ const invalidArgsMsg = /Incorrect value of args option/;
const invalidOptionsMsg = /"options" argument must be an object/;
const invalidFileMsg =
/^TypeError: "file" argument must be a non-empty string$/;
const empty = common.fixturesDir + '/empty.js';
const empty = `${common.fixturesDir}/empty.js`;
assert.throws(function() {
const child = spawn(invalidcmd, 'this is not an array');

8
test/parallel/test-child-process-spawnsync-input.js

@ -30,8 +30,8 @@ const msgOut = 'this is stdout';
const msgErr = 'this is stderr';
// this is actually not os.EOL?
const msgOutBuf = Buffer.from(msgOut + '\n');
const msgErrBuf = Buffer.from(msgErr + '\n');
const msgOutBuf = Buffer.from(`${msgOut}\n`);
const msgErrBuf = Buffer.from(`${msgErr}\n`);
const args = [
'-e',
@ -117,5 +117,5 @@ verifyBufOutput(spawnSync(process.execPath, args));
ret = spawnSync(process.execPath, args, { encoding: 'utf8' });
checkSpawnSyncRet(ret);
assert.strictEqual(ret.stdout, msgOut + '\n');
assert.strictEqual(ret.stderr, msgErr + '\n');
assert.strictEqual(ret.stdout, `${msgOut}\n`);
assert.strictEqual(ret.stderr, `${msgErr}\n`);

2
test/parallel/test-child-process-spawnsync-maxbuf.js

@ -5,7 +5,7 @@ const spawnSync = require('child_process').spawnSync;
const msgOut = 'this is stdout';
// This is actually not os.EOL?
const msgOutBuf = Buffer.from(msgOut + '\n');
const msgOutBuf = Buffer.from(`${msgOut}\n`);
const args = [
'-e',

2
test/parallel/test-child-process-stdin.js

@ -39,7 +39,7 @@ let response = '';
cat.stdout.setEncoding('utf8');
cat.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
console.log(`stdout: ${chunk}`);
response += chunk;
});

6
test/parallel/test-cli-eval.js

@ -203,7 +203,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
const opt = ' --eval "console.log(process.argv.slice(1).join(\' \'))"';
const cmd = `${nodejs}${opt} -- ${args}`;
child.exec(cmd, common.mustCall(function(err, stdout, stderr) {
assert.strictEqual(stdout, args + '\n');
assert.strictEqual(stdout, `${args}\n`);
assert.strictEqual(stderr, '');
assert.strictEqual(err, null);
}));
@ -212,7 +212,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
const popt = ' --print "process.argv.slice(1).join(\' \')"';
const pcmd = `${nodejs}${popt} -- ${args}`;
child.exec(pcmd, common.mustCall(function(err, stdout, stderr) {
assert.strictEqual(stdout, args + '\n');
assert.strictEqual(stdout, `${args}\n`);
assert.strictEqual(stderr, '');
assert.strictEqual(err, null);
}));
@ -222,7 +222,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
// filename.
const filecmd = `${nodejs} -- ${__filename} ${args}`;
child.exec(filecmd, common.mustCall(function(err, stdout, stderr) {
assert.strictEqual(stdout, args + '\n');
assert.strictEqual(stdout, `${args}\n`);
assert.strictEqual(stderr, '');
assert.strictEqual(err, null);
}));

7
test/parallel/test-cli-node-options.js

@ -31,8 +31,7 @@ function disallow(opt) {
const options = {env: {NODE_OPTIONS: opt}};
exec(process.execPath, options, common.mustCall(function(err) {
const message = err.message.split(/\r?\n/)[1];
const expect = process.execPath + ': ' + opt +
' is not allowed in NODE_OPTIONS';
const expect = `${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;
assert.strictEqual(err.code, 9);
assert.strictEqual(message, expect);
@ -41,7 +40,7 @@ function disallow(opt) {
const printA = require.resolve('../fixtures/printA.js');
expect('-r ' + printA, 'A\nB\n');
expect(`-r ${printA}`, 'A\nB\n');
expect('--no-deprecation', 'B\n');
expect('--no-warnings', 'B\n');
expect('--trace-warnings', 'B\n');
@ -75,7 +74,7 @@ function expect(opt, want) {
if (!RegExp(want).test(stdout)) {
console.error('For %j, failed to find %j in: <\n%s\n>',
opt, expect, stdout);
assert(false, 'Expected ' + expect);
assert(false, `Expected ${expect}`);
}
}));
}

12
test/parallel/test-cli-syntax.js

@ -31,7 +31,7 @@ const syntaxArgs = [
// no output should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
assert.strictEqual(c.stderr, '', 'stderr produced');
assert.strictEqual(c.status, 0, 'code === ' + c.status);
assert.strictEqual(c.status, 0, `code === ${c.status}`);
});
});
@ -59,7 +59,7 @@ const syntaxArgs = [
const match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m);
assert(match, 'stderr incorrect');
assert.strictEqual(c.status, 1, 'code === ' + c.status);
assert.strictEqual(c.status, 1, `code === ${c.status}`);
});
});
@ -82,7 +82,7 @@ const syntaxArgs = [
const match = c.stderr.match(/^Error: Cannot find module/m);
assert(match, 'stderr incorrect');
assert.strictEqual(c.status, 1, 'code === ' + c.status);
assert.strictEqual(c.status, 1, `code === ${c.status}`);
});
});
@ -96,7 +96,7 @@ syntaxArgs.forEach(function(args) {
assert.strictEqual(c.stdout, '', 'stdout produced');
assert.strictEqual(c.stderr, '', 'stderr produced');
assert.strictEqual(c.status, 0, 'code === ' + c.status);
assert.strictEqual(c.status, 0, `code === ${c.status}`);
});
// should throw if code piped from stdin with --check has bad syntax
@ -115,7 +115,7 @@ syntaxArgs.forEach(function(args) {
const match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m);
assert(match, 'stderr incorrect');
assert.strictEqual(c.status, 1, 'code === ' + c.status);
assert.strictEqual(c.status, 1, `code === ${c.status}`);
});
// should throw if -c and -e flags are both passed
@ -130,6 +130,6 @@ syntaxArgs.forEach(function(args) {
)
);
assert.strictEqual(c.status, 9, 'code === ' + c.status);
assert.strictEqual(c.status, 9, `code === ${c.status}`);
});
});

4
test/parallel/test-cluster-bind-twice.js

@ -54,14 +54,14 @@ if (!id) {
a.on('exit', common.mustCall((c) => {
if (c) {
b.send('QUIT');
throw new Error('A exited with ' + c);
throw new Error(`A exited with ${c}`);
}
}));
b.on('exit', common.mustCall((c) => {
if (c) {
a.send('QUIT');
throw new Error('B exited with ' + c);
throw new Error(`B exited with ${c}`);
}
}));

2
test/parallel/test-cluster-eaccess.js

@ -58,7 +58,7 @@ if (cluster.isMaster) {
} else {
common.refreshTmpDir();
const cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js',
const cp = fork(`${common.fixturesDir}/listen-on-socket-and-exit.js`,
{ stdio: 'inherit' });
// message from the child indicates it's ready and listening

4
test/parallel/test-cluster-eaddrinuse.js

@ -29,8 +29,8 @@ const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');
const id = '' + process.argv[2];
const port = '' + process.argv[3];
const id = String(process.argv[2]);
const port = String(process.argv[3]);
if (id === 'undefined') {
const server = net.createServer(common.mustNotCall());

7
test/parallel/test-cluster-message.js

@ -123,7 +123,7 @@ if (cluster.isWorker) {
if (data.code === 'received message') {
check('worker', data.echo === 'message from master');
} else {
throw new Error('wrong TCP message received: ' + data);
throw new Error(`wrong TCP message received: ${data}`);
}
});
@ -139,9 +139,8 @@ if (cluster.isWorker) {
process.once('exit', function() {
forEach(checks, function(check, type) {
assert.ok(check.receive, 'The ' + type + ' did not receive any message');
assert.ok(check.correct,
'The ' + type + ' did not get the correct message');
assert.ok(check.receive, `The ${type} did not receive any message`);
assert.ok(check.correct, `The ${type} did not get the correct message`);
});
});
}

7
test/parallel/test-cluster-worker-exit.js

@ -125,9 +125,8 @@ function checkResults(expected_results, results) {
const actual = results[k];
const expected = expected_results[k];
assert.strictEqual(actual,
expected && expected.length ? expected[0] : expected,
(expected[1] || '') +
` [expected: ${expected[0]} / actual: ${actual}]`);
assert.strictEqual(
actual, expected && expected.length ? expected[0] : expected,
`${expected[1] || ''} [expected: ${expected[0]} / actual: ${actual}]`);
}
}

7
test/parallel/test-cluster-worker-kill.js

@ -111,9 +111,8 @@ function checkResults(expected_results, results) {
const actual = results[k];
const expected = expected_results[k];
assert.strictEqual(actual,
expected && expected.length ? expected[0] : expected,
(expected[1] || '') +
` [expected: ${expected[0]} / actual: ${actual}]`);
assert.strictEqual(
actual, expected && expected.length ? expected[0] : expected,
`${expected[1] || ''} [expected: ${expected[0]} / actual: ${actual}]`);
}
}

8
test/parallel/test-console.js

@ -123,13 +123,13 @@ const expectedStrings = [
];
for (const expected of expectedStrings) {
assert.strictEqual(expected + '\n', strings.shift());
assert.strictEqual(expected + '\n', errStrings.shift());
assert.strictEqual(`${expected}\n`, strings.shift());
assert.strictEqual(`${expected}\n`, errStrings.shift());
}
for (const expected of expectedStrings) {
assert.strictEqual(expected + '\n', strings.shift());
assert.strictEqual(expected + '\n', errStrings.shift());
assert.strictEqual(`${expected}\n`, strings.shift());
assert.strictEqual(`${expected}\n`, errStrings.shift());
}
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",

2
test/parallel/test-crypto-authenticated.js

@ -334,7 +334,7 @@ for (const i in TEST_CASES) {
const test = TEST_CASES[i];
if (!ciphers.includes(test.algo)) {
common.skip('unsupported ' + test.algo + ' test');
common.skip(`unsupported ${test.algo} test`);
continue;
}

27
test/parallel/test-crypto-binary-default.js

@ -37,17 +37,16 @@ const fs = require('fs');
const path = require('path');
const tls = require('tls');
const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
const fixtDir = common.fixturesDir;
crypto.DEFAULT_ENCODING = 'latin1';
// Test Certificates
const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
const certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
const rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
'ascii');
const rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
'ascii');
const certPem = fs.readFileSync(`${fixtDir}/test_cert.pem`, 'ascii');
const certPfx = fs.readFileSync(`${fixtDir}/test_cert.pfx`);
const keyPem = fs.readFileSync(`${fixtDir}/test_key.pem`, 'ascii');
const rsaPubPem = fs.readFileSync(`${fixtDir}/test_rsa_pubkey.pem`, 'ascii');
const rsaKeyPem = fs.readFileSync(`${fixtDir}/test_rsa_privkey.pem`, 'ascii');
// PFX tests
assert.doesNotThrow(function() {
@ -408,7 +407,7 @@ const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
assert.strictEqual(h1, h2, 'multipled updates');
// Test hashing for binary files
const fn = path.join(common.fixturesDir, 'sample.png');
const fn = path.join(fixtDir, 'sample.png');
const sha1Hash = crypto.createHash('sha1');
const fileStream = fs.createReadStream(fn);
fileStream.on('data', function(data) {
@ -617,11 +616,9 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
// Test RSA signing and verification
//
{
const privateKey = fs.readFileSync(
common.fixturesDir + '/test_rsa_privkey_2.pem');
const privateKey = fs.readFileSync(`${fixtDir}/test_rsa_privkey_2.pem`);
const publicKey = fs.readFileSync(
common.fixturesDir + '/test_rsa_pubkey_2.pem');
const publicKey = fs.readFileSync(`${fixtDir}/test_rsa_pubkey_2.pem`);
const input = 'I AM THE WALRUS';
@ -649,11 +646,9 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
// Test DSA signing and verification
//
{
const privateKey = fs.readFileSync(
common.fixturesDir + '/test_dsa_privkey.pem');
const privateKey = fs.readFileSync(`${fixtDir}/test_dsa_privkey.pem`);
const publicKey = fs.readFileSync(
common.fixturesDir + '/test_dsa_pubkey.pem');
const publicKey = fs.readFileSync(`${fixtDir}/test_dsa_pubkey.pem`);
const input = 'I AM THE WALRUS';

6
test/parallel/test-crypto-certificate.js

@ -34,9 +34,9 @@ crypto.DEFAULT_ENCODING = 'buffer';
const fs = require('fs');
// Test Certificates
const spkacValid = fs.readFileSync(common.fixturesDir + '/spkac.valid');
const spkacFail = fs.readFileSync(common.fixturesDir + '/spkac.fail');
const spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem');
const spkacValid = fs.readFileSync(`${common.fixturesDir}/spkac.valid`);
const spkacFail = fs.readFileSync(`${common.fixturesDir}/spkac.fail`);
const spkacPem = fs.readFileSync(`${common.fixturesDir}/spkac.pem`);
const certificate = new crypto.Certificate();

11
test/parallel/test-crypto-fips.js

@ -31,19 +31,18 @@ function addToEnv(newVar, value) {
}
function testHelper(stream, args, expectedOutput, cmd, env) {
const fullArgs = args.concat(['-e', 'console.log(' + cmd + ')']);
const fullArgs = args.concat(['-e', `console.log(${cmd})`]);
const child = spawnSync(process.execPath, fullArgs, {
cwd: path.dirname(process.execPath),
env: env
});
console.error('Spawned child [pid:' + child.pid + '] with cmd \'' +
cmd + '\' expect %j with args \'' + args + '\'' +
' OPENSSL_CONF=%j', expectedOutput, env.OPENSSL_CONF);
console.error(
`Spawned child [pid:${child.pid}] with cmd '${cmd}' expect %j with args '${
args}' OPENSSL_CONF=%j`, expectedOutput, env.OPENSSL_CONF);
function childOk(child) {
console.error('Child #' + ++num_children_ok +
' [pid:' + child.pid + '] OK.');
console.error(`Child #${++num_children_ok} [pid:${child.pid}] OK.`);
}
function responseHandler(buffer, expectedOutput) {

28
test/parallel/test-crypto-rsa-dsa.js

@ -10,21 +10,19 @@ if (!common.hasCrypto) {
const constants = require('crypto').constants;
const crypto = require('crypto');
const fixtDir = common.fixturesDir;
// Test certificates
const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
const rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
'ascii');
const rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
'ascii');
const certPem = fs.readFileSync(`${fixtDir}/test_cert.pem`, 'ascii');
const keyPem = fs.readFileSync(`${fixtDir}/test_key.pem`, 'ascii');
const rsaPubPem = fs.readFileSync(`${fixtDir}/test_rsa_pubkey.pem`, 'ascii');
const rsaKeyPem = fs.readFileSync(`${fixtDir}/test_rsa_privkey.pem`, 'ascii');
const rsaKeyPemEncrypted = fs.readFileSync(
common.fixturesDir + '/test_rsa_privkey_encrypted.pem', 'ascii');
const dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem',
'ascii');
const dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem',
'ascii');
`${fixtDir}/test_rsa_privkey_encrypted.pem`, 'ascii');
const dsaPubPem = fs.readFileSync(`${fixtDir}/test_dsa_pubkey.pem`, 'ascii');
const dsaKeyPem = fs.readFileSync(`${fixtDir}/test_dsa_privkey.pem`, 'ascii');
const dsaKeyPemEncrypted = fs.readFileSync(
common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii');
`${fixtDir}/test_dsa_privkey_encrypted.pem`, 'ascii');
const decryptError =
/^Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt$/;
@ -178,11 +176,9 @@ assert.throws(() => {
// Test RSA signing and verification
//
{
const privateKey = fs.readFileSync(
common.fixturesDir + '/test_rsa_privkey_2.pem');
const privateKey = fs.readFileSync(`${fixtDir}/test_rsa_privkey_2.pem`);
const publicKey = fs.readFileSync(
common.fixturesDir + '/test_rsa_pubkey_2.pem');
const publicKey = fs.readFileSync(`${fixtDir}/test_rsa_pubkey_2.pem`);
const input = 'I AM THE WALRUS';

12
test/parallel/test-crypto-sign-verify.js

@ -12,8 +12,8 @@ if (!common.hasCrypto) {
const crypto = require('crypto');
// Test certificates
const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
const certPem = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`, 'ascii');
const keyPem = fs.readFileSync(`${common.fixturesDir}/test_key.pem`, 'ascii');
const modSize = 1024;
// Test signing and verifying
@ -265,10 +265,10 @@ const modSize = 1024;
const msgfile = path.join(common.tmpDir, 's5.msg');
fs.writeFileSync(msgfile, msg);
const cmd = '"' + common.opensslCli + '" dgst -sha256 -verify "' + pubfile +
'" -signature "' + sigfile +
'" -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-2 "' +
msgfile + '"';
const cmd =
`"${common.opensslCli}" dgst -sha256 -verify "${pubfile}" -signature "${
sigfile}" -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-2 "${
msgfile}"`;
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert(stdout.includes('Verified OK'));

6
test/parallel/test-crypto-verify-failure.js

@ -33,11 +33,11 @@ crypto.DEFAULT_ENCODING = 'buffer';
const fs = require('fs');
const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
const certPem = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`, 'ascii');
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
};
const server = tls.Server(options, (socket) => {

12
test/parallel/test-crypto.js

@ -35,10 +35,10 @@ const tls = require('tls');
crypto.DEFAULT_ENCODING = 'buffer';
// Test Certificates
const caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
const certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
const caPem = fs.readFileSync(`${common.fixturesDir}/test_ca.pem`, 'ascii');
const certPem = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`, 'ascii');
const certPfx = fs.readFileSync(`${common.fixturesDir}/test_cert.pfx`);
const keyPem = fs.readFileSync(`${common.fixturesDir}/test_key.pem`, 'ascii');
// 'this' safety
// https://github.com/joyent/node/issues/6690
@ -177,8 +177,8 @@ assert.throws(function() {
// $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \
// -out private_key.pem -nocrypt;
// Then open private_key.pem and change its header and footer.
const sha1_privateKey = fs.readFileSync(common.fixturesDir +
'/test_bad_rsa_privkey.pem', 'ascii');
const sha1_privateKey = fs.readFileSync(
`${common.fixturesDir}/test_bad_rsa_privkey.pem`, 'ascii');
// this would inject errors onto OpenSSL's error stack
crypto.createSign('sha1').sign(sha1_privateKey);
}, /asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag/);

2
test/parallel/test-cwd-enoent-preload.js

@ -10,7 +10,7 @@ if (common.isSunOS || common.isWindows || common.isAix) {
return;
}
const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
const abspathFile = require('path').join(common.fixturesDir, 'a.js');
common.refreshTmpDir();
fs.mkdirSync(dirname);

2
test/parallel/test-cwd-enoent-repl.js

@ -10,7 +10,7 @@ if (common.isSunOS || common.isWindows || common.isAix) {
return;
}
const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
common.refreshTmpDir();
fs.mkdirSync(dirname);
process.chdir(dirname);

2
test/parallel/test-cwd-enoent.js

@ -10,7 +10,7 @@ if (common.isSunOS || common.isWindows || common.isAix) {
return;
}
const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
common.refreshTmpDir();
fs.mkdirSync(dirname);
process.chdir(dirname);

4
test/parallel/test-dgram-bind-shared-ports.js

@ -54,12 +54,12 @@ if (cluster.isMaster) {
socket1.on('error', (err) => {
// no errors expected
process.send('socket1:' + err.code);
process.send(`socket1:${err.code}`);
});
socket2.on('error', (err) => {
// an error is expected on the second worker
process.send('socket2:' + err.code);
process.send(`socket2:${err.code}`);
});
socket1.bind({

2
test/parallel/test-dgram-error-message-address.js

@ -49,7 +49,7 @@ socket_ipv6.on('error', common.mustCall(function(e) {
const allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT'];
assert.notStrictEqual(allowed.indexOf(e.code), -1);
assert.strictEqual(e.port, undefined);
assert.strictEqual(e.message, 'bind ' + e.code + ' 111::1');
assert.strictEqual(e.message, `bind ${e.code} 111::1`);
assert.strictEqual(e.address, '111::1');
socket_ipv6.close();
}));

10
test/parallel/test-domain-enter-exit.js

@ -41,20 +41,20 @@ c.name = 'c';
a.enter(); // push
assert.deepStrictEqual(domain._stack, [a],
'a not pushed: ' + names(domain._stack));
`a not pushed: ${names(domain._stack)}`);
b.enter(); // push
assert.deepStrictEqual(domain._stack, [a, b],
'b not pushed: ' + names(domain._stack));
`b not pushed: ${names(domain._stack)}`);
c.enter(); // push
assert.deepStrictEqual(domain._stack, [a, b, c],
'c not pushed: ' + names(domain._stack));
`c not pushed: ${names(domain._stack)}`);
b.exit(); // pop
assert.deepStrictEqual(domain._stack, [a],
'b and c not popped: ' + names(domain._stack));
`b and c not popped: ${names(domain._stack)}`);
b.enter(); // push
assert.deepStrictEqual(domain._stack, [a, b],
'b not pushed: ' + names(domain._stack));
`b not pushed: ${names(domain._stack)}`);

9
test/parallel/test-domain-uncaught-exception.js

@ -184,16 +184,15 @@ if (process.argv[2] === 'child') {
test.expectedMessages.forEach(function(expectedMessage) {
if (test.messagesReceived === undefined ||
test.messagesReceived.indexOf(expectedMessage) === -1)
assert.fail('test ' + test.fn.name + ' should have sent message: ' +
expectedMessage + ' but didn\'t');
assert.fail(`test ${test.fn.name} should have sent message: ${
expectedMessage} but didn't`);
});
if (test.messagesReceived) {
test.messagesReceived.forEach(function(receivedMessage) {
if (test.expectedMessages.indexOf(receivedMessage) === -1) {
assert.fail('test ' + test.fn.name +
' should not have sent message: ' + receivedMessage +
' but did');
assert.fail(`test ${test.fn.name} should not have sent message: ${
receivedMessage} but did`);
}
});
}

10
test/parallel/test-domain-with-abort-on-uncaught-exception.js

@ -103,14 +103,8 @@ if (process.argv[2] === 'child') {
if (options.useTryCatch)
useTryCatchOpt = 'useTryCatch';
cmdToExec += process.argv[0] + ' ';
cmdToExec += (cmdLineOption ? cmdLineOption : '') + ' ';
cmdToExec += process.argv[1] + ' ';
cmdToExec += [
'child',
throwInDomainErrHandlerOpt,
useTryCatchOpt
].join(' ');
cmdToExec += `${process.argv[0]} ${cmdLineOption ? cmdLineOption : ''} ${
process.argv[1]} child ${throwInDomainErrHandlerOpt} ${useTryCatchOpt}`;
const child = exec(cmdToExec);

4
test/parallel/test-domain.js

@ -251,9 +251,7 @@ assert.strictEqual(result, 'return value');
// check if the executed function take in count the applied parameters
result = d.run(function(a, b) {
return a + ' ' + b;
}, 'return', 'value');
result = d.run((a, b) => `${a} ${b}`, 'return', 'value');
assert.strictEqual(result, 'return value');

4
test/parallel/test-dsa-fips-invalid-key.js

@ -12,8 +12,8 @@ const fs = require('fs');
const input = 'hello';
const dsapri = fs.readFileSync(common.fixturesDir +
'/keys/dsa_private_1025.pem');
const dsapri = fs.readFileSync(
`${common.fixturesDir}/keys/dsa_private_1025.pem`);
const sign = crypto.createSign('DSS1');
sign.update(input);

3
test/parallel/test-error-reporting.js

@ -26,8 +26,7 @@ const exec = require('child_process').exec;
const path = require('path');
function errExec(script, callback) {
const cmd = '"' + process.argv[0] + '" "' +
path.join(common.fixturesDir, script) + '"';
const cmd = `"${process.argv[0]}" "${path.join(common.fixturesDir, script)}"`;
return exec(cmd, function(err, stdout, stderr) {
// There was some error
assert.ok(err);

2
test/parallel/test-eval.js

@ -29,7 +29,7 @@ const cmd = [
`"${process.execPath}"`, '-e',
'"console.error(process.argv)"',
'foo', 'bar'].join(' ');
const expected = util.format([process.execPath, 'foo', 'bar']) + '\n';
const expected = `${util.format([process.execPath, 'foo', 'bar'])}\n`;
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.ifError(err);
assert.strictEqual(stderr, expected);

2
test/parallel/test-exception-handler2.js

@ -24,7 +24,7 @@ const common = require('../common');
const assert = require('assert');
process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
console.log(`Caught exception: ${err}`);
});
setTimeout(common.mustCall(function() {

8
test/parallel/test-file-write-stream2.js

@ -43,9 +43,9 @@ process.on('exit', function() {
console.log(' Test callback events missing or out of order:');
console.log(' expected: %j', cb_expected);
console.log(' occurred: %j', cb_occurred);
assert.strictEqual(cb_occurred, cb_expected,
'events missing or out of order: "' +
cb_occurred + '" !== "' + cb_expected + '"');
assert.strictEqual(
cb_occurred, cb_expected,
`events missing or out of order: "${cb_occurred}" !== "${cb_expected}"`);
} else {
console.log('ok');
}
@ -101,7 +101,7 @@ file.on('error', function(err) {
for (let i = 0; i < 11; i++) {
const ret = file.write(i + '');
const ret = file.write(String(i));
console.error('%d %j', i, ret);
// return false when i hits 10

6
test/parallel/test-file-write-stream3.js

@ -44,9 +44,9 @@ process.on('exit', function() {
console.log(' Test callback events missing or out of order:');
console.log(' expected: %j', cb_expected);
console.log(' occurred: %j', cb_occurred);
assert.strictEqual(cb_occurred, cb_expected,
'events missing or out of order: "' +
cb_occurred + '" !== "' + cb_expected + '"');
assert.strictEqual(
cb_occurred, cb_expected,
`events missing or out of order: "${cb_occurred}" !== "${cb_expected}"`);
}
});

2
test/parallel/test-fs-append-file-sync.js

@ -83,7 +83,7 @@ if (!common.isWindows) {
const fileData4 = fs.readFileSync(filename4);
assert.strictEqual(Buffer.byteLength('' + num) + currentFileData.length,
assert.strictEqual(Buffer.byteLength(String(num)) + currentFileData.length,
fileData4.length);
// test that appendFile accepts file descriptors

2
test/parallel/test-fs-append-file.js

@ -109,7 +109,7 @@ fs.appendFile(filename4, n, { mode: m }, function(e) {
fs.readFile(filename4, function(e, buffer) {
assert.ifError(e);
ncallbacks++;
assert.strictEqual(Buffer.byteLength('' + n) + currentFileData.length,
assert.strictEqual(Buffer.byteLength(String(n)) + currentFileData.length,
buffer.length);
});
});

2
test/parallel/test-fs-buffertype-writesync.js

@ -16,5 +16,5 @@ common.refreshTmpDir();
v.forEach((value) => {
const fd = fs.openSync(filePath, 'w');
fs.writeSync(fd, value);
assert.strictEqual(fs.readFileSync(filePath).toString(), value + '');
assert.strictEqual(fs.readFileSync(filePath).toString(), String(value));
});

7
test/parallel/test-fs-error-messages.js

@ -225,7 +225,8 @@ try {
}
process.on('exit', function() {
assert.strictEqual(expected, errors.length,
'Test fs sync exceptions raised, got ' + errors.length +
' expected ' + expected);
assert.strictEqual(
expected, errors.length,
`Test fs sync exceptions raised, got ${errors.length} expected ${expected}`
);
});

4
test/parallel/test-fs-exists.js

@ -29,9 +29,9 @@ fs.exists(f, common.mustCall(function(y) {
assert.strictEqual(y, true);
}));
fs.exists(f + '-NO', common.mustCall(function(y) {
fs.exists(`${f}-NO`, common.mustCall(function(y) {
assert.strictEqual(y, false);
}));
assert(fs.existsSync(f));
assert(!fs.existsSync(f + '-NO'));
assert(!fs.existsSync(`${f}-NO`));

6
test/parallel/test-fs-mkdir.js

@ -34,7 +34,7 @@ function unlink(pathname) {
common.refreshTmpDir();
{
const pathname = common.tmpDir + '/test1';
const pathname = `${common.tmpDir}/test1`;
unlink(pathname);
@ -49,7 +49,7 @@ common.refreshTmpDir();
}
{
const pathname = common.tmpDir + '/test2';
const pathname = `${common.tmpDir}/test2`;
unlink(pathname);
@ -64,7 +64,7 @@ common.refreshTmpDir();
}
{
const pathname = common.tmpDir + '/test3';
const pathname = `${common.tmpDir}/test3`;
unlink(pathname);
fs.mkdirSync(pathname);

5
test/parallel/test-fs-non-number-arguments-throw.js

@ -29,6 +29,7 @@ assert.throws(function() {
"start as string didn't throw an error for createWriteStream");
saneEmitter.on('data', common.mustCall(function(data) {
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +
data.toString('utf8') + ' instead of ' + sanity);
assert.strictEqual(
sanity, data.toString('utf8'),
`read ${data.toString('utf8')} instead of ${sanity}`);
}));

2
test/parallel/test-fs-readdir.js

@ -12,7 +12,7 @@ common.refreshTmpDir();
// Create the necessary files
files.forEach(function(currentFile) {
fs.closeSync(fs.openSync(readdirDir + '/' + currentFile, 'w'));
fs.closeSync(fs.openSync(`${readdirDir}/${currentFile}`, 'w'));
});
// Check the readdir Sync version

4
test/parallel/test-fs-readfile-error.js

@ -34,13 +34,13 @@ if (common.isFreeBSD) {
function test(env, cb) {
const filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
const execPath = '"' + process.execPath + '" "' + filename + '"';
const execPath = `"${process.execPath}" "${filename}"`;
const options = { env: Object.assign(process.env, env) };
exec(execPath, options, common.mustCall((err, stdout, stderr) => {
assert(err);
assert.strictEqual(stdout, '');
assert.notStrictEqual(stderr, '');
cb('' + stderr);
cb(String(stderr));
}));
}

86
test/parallel/test-fs-realpath.js

@ -29,6 +29,7 @@ let async_completed = 0;
let async_expected = 0;
const unlink = [];
let skipSymlinks = false;
const tmpDir = common.tmpDir;
common.refreshTmpDir();
@ -62,11 +63,11 @@ if (common.isWindows) {
function tmp(p) {
return path.join(common.tmpDir, p);
return path.join(tmpDir, p);
}
const targetsAbsDir = path.join(common.tmpDir, 'targets');
const tmpAbsDir = common.tmpDir;
const targetsAbsDir = path.join(tmpDir, 'targets');
const tmpAbsDir = tmpDir;
// Set up targetsAbsDir and expected subdirectories
fs.mkdirSync(targetsAbsDir);
@ -105,10 +106,10 @@ function test_simple_relative_symlink(callback) {
common.skip('symlink test (no privs)');
return runNextTest();
}
const entry = common.tmpDir + '/symlink';
const expected = common.tmpDir + '/cycles/root.js';
const entry = `${tmpDir}/symlink`;
const expected = `${tmpDir}/cycles/root.js`;
[
[entry, '../' + common.tmpDirName + '/cycles/root.js']
[entry, `../${common.tmpDirName}/cycles/root.js`]
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
@ -131,8 +132,8 @@ function test_simple_absolute_symlink(callback) {
console.log('using type=%s', type);
const entry = tmpAbsDir + '/symlink';
const expected = common.fixturesDir + '/nested-index/one';
const entry = `${tmpAbsDir}/symlink`;
const expected = `${common.fixturesDir}/nested-index/one`;
[
[entry, expected]
].forEach(function(t) {
@ -212,11 +213,11 @@ function test_cyclic_link_protection(callback) {
common.skip('symlink test (no privs)');
return runNextTest();
}
const entry = path.join(common.tmpDir, '/cycles/realpath-3a');
const entry = path.join(tmpDir, '/cycles/realpath-3a');
[
[entry, '../cycles/realpath-3b'],
[path.join(common.tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
[path.join(common.tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
fs.symlinkSync(t[1], t[0], 'dir');
@ -239,10 +240,10 @@ function test_cyclic_link_overprotection(callback) {
common.skip('symlink test (no privs)');
return runNextTest();
}
const cycles = common.tmpDir + '/cycles';
const cycles = `${tmpDir}/cycles`;
const expected = fs.realpathSync(cycles);
const folder = cycles + '/folder';
const link = folder + '/cycles';
const folder = `${cycles}/folder`;
const link = `${folder}/cycles`;
let testPath = cycles;
testPath += '/folder/cycles'.repeat(10);
try { fs.unlinkSync(link); } catch (ex) {}
@ -264,12 +265,12 @@ function test_relative_input_cwd(callback) {
// we need to calculate the relative path to the tmp dir from cwd
const entrydir = process.cwd();
const entry = path.relative(entrydir,
path.join(common.tmpDir + '/cycles/realpath-3a'));
const expected = common.tmpDir + '/cycles/root.js';
path.join(`${tmpDir}/cycles/realpath-3a`));
const expected = `${tmpDir}/cycles/root.js`;
[
[entry, '../cycles/realpath-3b'],
[common.tmpDir + '/cycles/realpath-3b', '../cycles/realpath-3c'],
[common.tmpDir + '/cycles/realpath-3c', 'root.js']
[`${tmpDir}/cycles/realpath-3b`, '../cycles/realpath-3c'],
[`${tmpDir}/cycles/realpath-3c`, 'root.js']
].forEach(function(t) {
const fn = t[0];
console.error('fn=%j', fn);
@ -317,16 +318,16 @@ function test_deep_symlink_mix(callback) {
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
try {
[
[entry, common.tmpDir + '/node-test-realpath-d1/foo'],
[entry, `${tmpDir}/node-test-realpath-d1/foo`],
[tmp('node-test-realpath-d1'),
common.tmpDir + '/node-test-realpath-d2'],
`${tmpDir}/node-test-realpath-d2`],
[tmp('node-test-realpath-d2/foo'), '../node-test-realpath-f2'],
[tmp('node-test-realpath-f2'), targetsAbsDir +
'/nested-index/one/realpath-c'],
[targetsAbsDir + '/nested-index/one/realpath-c', targetsAbsDir +
'/nested-index/two/realpath-c'],
[targetsAbsDir + '/nested-index/two/realpath-c',
common.tmpDir + '/cycles/root.js']
[tmp('node-test-realpath-f2'),
`${targetsAbsDir}/nested-index/one/realpath-c`],
[`${targetsAbsDir}/nested-index/one/realpath-c`,
`${targetsAbsDir}/nested-index/two/realpath-c`],
[`${targetsAbsDir}/nested-index/two/realpath-c`,
`${tmpDir}/cycles/root.js`]
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
fs.symlinkSync(t[1], t[0]);
@ -335,7 +336,7 @@ function test_deep_symlink_mix(callback) {
} finally {
unlink.push(tmp('node-test-realpath-d2'));
}
const expected = tmpAbsDir + '/cycles/root.js';
const expected = `${tmpAbsDir}/cycles/root.js`;
assertEqualPath(fs.realpathSync(entry), path.resolve(expected));
asynctest(fs.realpath, [entry], callback, function(err, result) {
assertEqualPath(result, path.resolve(expected));
@ -346,8 +347,8 @@ function test_deep_symlink_mix(callback) {
function test_non_symlinks(callback) {
console.log('test_non_symlinks');
const entrydir = path.dirname(tmpAbsDir);
const entry = tmpAbsDir.substr(entrydir.length + 1) + '/cycles/root.js';
const expected = tmpAbsDir + '/cycles/root.js';
const entry = `${tmpAbsDir.substr(entrydir.length + 1)}/cycles/root.js`;
const expected = `${tmpAbsDir}/cycles/root.js`;
const origcwd = process.cwd();
process.chdir(entrydir);
assertEqualPath(fs.realpathSync(entry), path.resolve(expected));
@ -362,15 +363,15 @@ const upone = path.join(process.cwd(), '..');
function test_escape_cwd(cb) {
console.log('test_escape_cwd');
asynctest(fs.realpath, ['..'], cb, function(er, uponeActual) {
assertEqualPath(upone, uponeActual,
'realpath("..") expected: ' + path.resolve(upone) +
' actual:' + uponeActual);
assertEqualPath(
upone, uponeActual,
`realpath("..") expected: ${path.resolve(upone)} actual:${uponeActual}`);
});
}
const uponeActual = fs.realpathSync('..');
assertEqualPath(upone, uponeActual,
'realpathSync("..") expected: ' + path.resolve(upone) +
' actual:' + uponeActual);
assertEqualPath(
upone, uponeActual,
`realpathSync("..") expected: ${path.resolve(upone)} actual:${uponeActual}`);
// going up with .. multiple times
@ -442,7 +443,7 @@ function test_abs_with_kids(cb) {
console.log('using type=%s', type);
const root = tmpAbsDir + '/node-test-realpath-abs-kids';
const root = `${tmpAbsDir}/node-test-realpath-abs-kids`;
function cleanup() {
['/a/b/c/x.txt',
'/a/link'
@ -464,15 +465,15 @@ function test_abs_with_kids(cb) {
'/a/b',
'/a/b/c'
].forEach(function(folder) {
console.log('mkdir ' + root + folder);
console.log(`mkdir ${root}${folder}`);
fs.mkdirSync(root + folder, 0o700);
});
fs.writeFileSync(root + '/a/b/c/x.txt', 'foo');
fs.symlinkSync(root + '/a/b', root + '/a/link', type);
fs.writeFileSync(`${root}/a/b/c/x.txt`, 'foo');
fs.symlinkSync(`${root}/a/b`, `${root}/a/link`, type);
}
setup();
const linkPath = root + '/a/link/c/x.txt';
const expectPath = root + '/a/b/c/x.txt';
const linkPath = `${root}/a/link/c/x.txt`;
const expectPath = `${root}/a/b/c/x.txt`;
const actual = fs.realpathSync(linkPath);
// console.log({link:linkPath,expect:expectPath,actual:actual},'sync');
assertEqualPath(actual, path.resolve(expectPath));
@ -506,8 +507,7 @@ function runNextTest(err) {
assert.ifError(err);
const test = tests.shift();
if (!test) {
return console.log(numtests +
' subtests completed OK for fs.realpath');
return console.log(`${numtests} subtests completed OK for fs.realpath`);
}
testsRun++;
test(runNextTest);

2
test/parallel/test-fs-sir-writes-alot.js

@ -56,7 +56,7 @@ function testBuffer(b) {
for (let i = 0; i < b.length; i++) {
bytesChecked++;
if (b[i] !== 'a'.charCodeAt(0) && b[i] !== '\n'.charCodeAt(0)) {
throw new Error('invalid char ' + i + ',' + b[i]);
throw new Error(`invalid char ${i},${b[i]}`);
}
}
}

14
test/parallel/test-fs-stat.js

@ -77,25 +77,25 @@ fs.stat(__filename, common.mustCall(function(err, s) {
console.dir(s);
console.log('isDirectory: ' + JSON.stringify(s.isDirectory()));
console.log(`isDirectory: ${JSON.stringify(s.isDirectory())}`);
assert.strictEqual(false, s.isDirectory());
console.log('isFile: ' + JSON.stringify(s.isFile()));
console.log(`isFile: ${JSON.stringify(s.isFile())}`);
assert.strictEqual(true, s.isFile());
console.log('isSocket: ' + JSON.stringify(s.isSocket()));
console.log(`isSocket: ${JSON.stringify(s.isSocket())}`);
assert.strictEqual(false, s.isSocket());
console.log('isBlockDevice: ' + JSON.stringify(s.isBlockDevice()));
console.log(`isBlockDevice: ${JSON.stringify(s.isBlockDevice())}`);
assert.strictEqual(false, s.isBlockDevice());
console.log('isCharacterDevice: ' + JSON.stringify(s.isCharacterDevice()));
console.log(`isCharacterDevice: ${JSON.stringify(s.isCharacterDevice())}`);
assert.strictEqual(false, s.isCharacterDevice());
console.log('isFIFO: ' + JSON.stringify(s.isFIFO()));
console.log(`isFIFO: ${JSON.stringify(s.isFIFO())}`);
assert.strictEqual(false, s.isFIFO());
console.log('isSymbolicLink: ' + JSON.stringify(s.isSymbolicLink()));
console.log(`isSymbolicLink: ${JSON.stringify(s.isSymbolicLink())}`);
assert.strictEqual(false, s.isSymbolicLink());
assert.ok(s.mtime instanceof Date);

6
test/parallel/test-fs-stream-double-close.js

@ -29,9 +29,9 @@ test1(fs.createReadStream(__filename));
test2(fs.createReadStream(__filename));
test3(fs.createReadStream(__filename));
test1(fs.createWriteStream(common.tmpDir + '/dummy1'));
test2(fs.createWriteStream(common.tmpDir + '/dummy2'));
test3(fs.createWriteStream(common.tmpDir + '/dummy3'));
test1(fs.createWriteStream(`${common.tmpDir}/dummy1`));
test2(fs.createWriteStream(`${common.tmpDir}/dummy2`));
test3(fs.createWriteStream(`${common.tmpDir}/dummy3`));
function test1(stream) {
stream.destroy();

4
test/parallel/test-fs-symlink-dir-junction-relative.js

@ -48,8 +48,8 @@ function verifyLink(linkPath) {
const stats = fs.lstatSync(linkPath);
assert.ok(stats.isSymbolicLink());
const data1 = fs.readFileSync(linkPath + '/x.txt', 'ascii');
const data2 = fs.readFileSync(linkTarget + '/x.txt', 'ascii');
const data1 = fs.readFileSync(`${linkPath}/x.txt`, 'ascii');
const data2 = fs.readFileSync(`${linkTarget}/x.txt`, 'ascii');
assert.strictEqual(data1, data2);
// Clean up.

4
test/parallel/test-fs-symlink-dir-junction.js

@ -31,8 +31,8 @@ const linkPath = path.join(common.tmpDir, 'cycles_link');
common.refreshTmpDir();
console.log('linkData: ' + linkData);
console.log('linkPath: ' + linkPath);
console.log(`linkData: ${linkData}`);
console.log(`linkPath: ${linkPath}`);
fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) {
assert.ifError(err);

2
test/parallel/test-fs-timestamp-parsing-error.js

@ -5,7 +5,7 @@ const assert = require('assert');
[Infinity, -Infinity, NaN].forEach((input) => {
assert.throws(() => fs._toUnixTimestamp(input),
new RegExp('^Error: Cannot parse time: ' + input + '$'));
new RegExp(`^Error: Cannot parse time: ${input}$`));
});
assert.throws(() => fs._toUnixTimestamp({}),

2
test/parallel/test-fs-truncate-GH-6233.js

@ -24,7 +24,7 @@ const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const filename = common.tmpDir + '/truncate-file.txt';
const filename = `${common.tmpDir}/truncate-file.txt`;
common.refreshTmpDir();

2
test/parallel/test-fs-write-file.js

@ -77,7 +77,7 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
fs.readFile(filename3, common.mustCall(function(e, buffer) {
assert.ifError(e);
assert.strictEqual(Buffer.byteLength('' + n), buffer.length);
assert.strictEqual(Buffer.byteLength(String(n)), buffer.length);
}));
}));

2
test/parallel/test-fs-write-stream-err.js

@ -26,7 +26,7 @@ const fs = require('fs');
common.refreshTmpDir();
const stream = fs.createWriteStream(common.tmpDir + '/out', {
const stream = fs.createWriteStream(`${common.tmpDir}/out`, {
highWaterMark: 10
});
const err = new Error('BAM');

2
test/parallel/test-fs-write-string-coerce.js

@ -9,7 +9,7 @@ common.refreshTmpDir();
const fn = path.join(common.tmpDir, 'write-string-coerce.txt');
const data = true;
const expected = data + '';
const expected = String(data);
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
assert.ifError(err);

4
test/parallel/test-http-abort-client.js

@ -38,11 +38,11 @@ server.listen(0, common.mustCall(function() {
}, common.mustCall(function(res) {
server.close();
console.log('Got res: ' + res.statusCode);
console.log(`Got res: ${res.statusCode}`);
console.dir(res.headers);
res.on('data', function(chunk) {
console.log('Read ' + chunk.length + ' bytes');
console.log(`Read ${chunk.length} bytes`);
console.log(' chunk=%j', chunk.toString());
});

4
test/parallel/test-http-abort-queued.js

@ -80,11 +80,11 @@ server.listen(0, function() {
assert.strictEqual(Object.keys(agent.sockets).length, 1);
assert.strictEqual(Object.keys(agent.requests).length, 1);
console.log('Got res: ' + res1.statusCode);
console.log(`Got res: ${res1.statusCode}`);
console.dir(res1.headers);
res1.on('data', function(chunk) {
console.log('Read ' + chunk.length + ' bytes');
console.log(`Read ${chunk.length} bytes`);
console.log(' chunk=%j', chunk.toString());
complete();
});

4
test/parallel/test-http-after-connect.js

@ -64,7 +64,7 @@ server.listen(0, function() {
function doRequest(i) {
http.get({
port: server.address().port,
path: '/request' + i
path: `/request${i}`
}, common.mustCall(function(res) {
console.error('Client got GET response');
let data = '';
@ -73,7 +73,7 @@ function doRequest(i) {
data += chunk;
});
res.on('end', function() {
assert.strictEqual(data, '/request' + i);
assert.strictEqual(data, `/request${i}`);
++clientResponses;
if (clientResponses === 2) {
server.close();

2
test/parallel/test-http-agent-error-on-idle.js

@ -29,7 +29,7 @@ server.listen(0, function() {
process.nextTick(function() {
const freeSockets = agent.freeSockets[socketKey];
assert.strictEqual(freeSockets.length, 1,
'expect a free socket on ' + socketKey);
`expect a free socket on ${socketKey}`);
//generate a random error on the free socket
const freeSocket = freeSockets[0];

2
test/parallel/test-http-agent-getname.js

@ -35,4 +35,4 @@ for (const family of [0, null, undefined, 'bogus'])
assert.strictEqual(agent.getName({ family }), 'localhost::');
for (const family of [4, 6])
assert.strictEqual(agent.getName({ family }), 'localhost:::' + family);
assert.strictEqual(agent.getName({ family }), `localhost:::${family}`);

2
test/parallel/test-http-agent-maxsockets.js

@ -30,7 +30,7 @@ function done() {
}
const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
assert.strictEqual(freepool.length, 2,
'expect keep 2 free sockets, but got ' + freepool.length);
`expect keep 2 free sockets, but got ${freepool.length}`);
agent.destroy();
server.close();
}

2
test/parallel/test-http-buffer-sanity.js

@ -58,7 +58,7 @@ const web = http.Server(function(req, res) {
});
req.connection.on('error', function(e) {
console.log('http server-side error: ' + e.message);
console.log(`http server-side error: ${e.message}`);
process.exit(1);
});
});

2
test/parallel/test-http-chunk-problem.js

@ -82,7 +82,7 @@ cp.exec(ddcmd, function(err, stdout, stderr) {
// End the response on exit (and log errors)
cat.on('exit', (code) => {
if (code !== 0) {
console.error('subprocess exited with code ' + code);
console.error(`subprocess exited with code ${code}`);
process.exit(1);
}
});

8
test/parallel/test-http-client-abort.js

@ -36,7 +36,7 @@ const server = http.Server(function(req, res) {
// event like "aborted" or something.
req.on('aborted', function() {
clientAborts++;
console.log('Got abort ' + clientAborts);
console.log(`Got abort ${clientAborts}`);
if (clientAborts === N) {
console.log('All aborts detected, you win.');
server.close();
@ -52,10 +52,10 @@ server.listen(0, function() {
console.log('Server listening.');
for (let i = 0; i < N; i++) {
console.log('Making client ' + i);
const options = { port: this.address().port, path: '/?id=' + i };
console.log(`Making client ${i}`);
const options = { port: this.address().port, path: `/?id=${i}` };
const req = http.get(options, function(res) {
console.log('Client response code ' + res.statusCode);
console.log(`Client response code ${res.statusCode}`);
res.resume();
if (++responses === N) {

2
test/parallel/test-http-client-agent.js

@ -49,7 +49,7 @@ server.listen(0, function() {
function request(i) {
const req = http.get({
port: server.address().port,
path: '/' + i
path: `/${i}`
}, function(res) {
const socket = req.socket;
socket.on('close', function() {

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save