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>
This commit is contained in:
parent
6bcf65d4a7
commit
8b76c3e60c
@ -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\'); });',
|
||||
];
|
||||
|
@ -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`);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
}));
|
||||
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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++;
|
||||
|
@ -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;
|
||||
|
@ -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']);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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'
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
}));
|
||||
|
@ -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');
|
||||
|
@ -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`);
|
||||
|
@ -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',
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
}));
|
||||
|
@ -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}`);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -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}`);
|
||||
});
|
||||
});
|
||||
|
@ -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}`);
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -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}]`);
|
||||
}
|
||||
}
|
||||
|
@ -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}]`);
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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,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'));
|
||||
|
@ -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) => {
|
||||
|
@ -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/);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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({
|
||||
|
@ -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();
|
||||
}));
|
||||
|
@ -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)}`);
|
||||
|
@ -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`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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');
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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}"`);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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));
|
||||
});
|
||||
|
@ -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}`
|
||||
);
|
||||
});
|
||||
|
@ -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`));
|
||||
|
@ -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);
|
||||
|
@ -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}`);
|
||||
}));
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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({}),
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}));
|
||||
}));
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
});
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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];
|
||||
|
@ -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}`);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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) {
|
||||
|
@ -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 have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user