test: use tmpdir.resolve()

Subsystems: blob, child_process, common, crypto, http, http2,
readline, repl, snapshot, trace_events

PR-URL: https://github.com/nodejs/node/pull/49127
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This commit is contained in:
Livia Medeiros 2023-08-15 22:45:34 +09:00 committed by GitHub
parent 6a68794577
commit e738edce6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 92 additions and 154 deletions

View File

@ -15,13 +15,12 @@ const {
const {
unlink
} = require('fs/promises');
const path = require('path');
const { Blob } = require('buffer');
const tmpdir = require('../common/tmpdir');
const testfile = path.join(tmpdir.path, 'test-file-backed-blob.txt');
const testfile2 = path.join(tmpdir.path, 'test-file-backed-blob2.txt');
const testfile3 = path.join(tmpdir.path, 'test-file-backed-blob3.txt');
const testfile = tmpdir.resolve('test-file-backed-blob.txt');
const testfile2 = tmpdir.resolve('test-file-backed-blob2.txt');
const testfile3 = tmpdir.resolve('test-file-backed-blob3.txt');
tmpdir.refresh();
const data = `${'a'.repeat(1000)}${'b'.repeat(2000)}`;

View File

@ -27,13 +27,12 @@ const common = require('../common');
const tmpdir = require('../common/tmpdir');
const { addLibraryPath } = require('../common/shared-lib-util');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const { fork } = require('child_process');
const msg = { test: 'this' };
const nodePath = process.execPath;
const copyPath = path.join(tmpdir.path, 'node-copy.exe');
const copyPath = tmpdir.resolve('node-copy.exe');
addLibraryPath(process.env);

View File

@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const spawn = require('child_process').spawn;
const tmpdir = require('../common/tmpdir');
@ -18,7 +17,7 @@ const MB = KB * KB;
{
tmpdir.refresh();
const file = path.resolve(tmpdir.path, 'data.txt');
const file = tmpdir.resolve('data.txt');
const buf = Buffer.alloc(MB).fill('x');
// Most OS commands that deal with data, attach special meanings to new line -

View File

@ -7,7 +7,6 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const stream = require('stream');
const tmpdir = require('../common/tmpdir');
@ -72,7 +71,7 @@ function mstream(config) {
function fstream(config) {
const count = fstream.count++;
const filename = (name) => path.join(tmpdir.path, `${name}${count}`);
const filename = (name) => tmpdir.resolve(`${name}${count}`);
const { cipher, key, iv, aad, authTagLength, plaintextLength } = config;
const expected = Buffer.alloc(plaintextLength);

View File

@ -5,7 +5,6 @@ if (!common.hasCrypto)
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
const crypto = require('crypto');
const fixtures = require('../common/fixtures');
@ -617,9 +616,9 @@ assert.throws(
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const sigfile = path.join(tmpdir.path, 's5.sig');
const sigfile = tmpdir.resolve('s5.sig');
fs.writeFileSync(sigfile, s5);
const msgfile = path.join(tmpdir.path, 's5.msg');
const msgfile = tmpdir.resolve('s5.msg');
fs.writeFileSync(msgfile, msg);
const cmd =

View File

@ -3,7 +3,6 @@
require('../common');
const assert = require('assert');
const http = require('http');
const path = require('path');
const tmpdir = require('../common/tmpdir');
@ -41,7 +40,7 @@ assert.strictEqual(
);
// unix socket
const socketPath = path.join(tmpdir.path, 'foo', 'bar');
const socketPath = tmpdir.resolve('foo', 'bar');
assert.strictEqual(
agent.getName({
socketPath

View File

@ -39,7 +39,7 @@ const cp = require('child_process');
const tmpdir = require('../common/tmpdir');
const filename = require('path').join(tmpdir.path, 'big');
const filename = tmpdir.resolve('big');
let server;
function executeRequest(cb) {

View File

@ -23,7 +23,6 @@
const common = require('../common');
const http = require('http');
const fs = require('fs');
const path = require('path');
const Countdown = require('../common/countdown');
const NUMBER_OF_STREAMS = 2;
@ -32,7 +31,7 @@ const countdown = new Countdown(NUMBER_OF_STREAMS, () => server.close());
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const file = path.join(tmpdir.path, 'http-pipe-fs-test.txt');
const file = tmpdir.resolve('http-pipe-fs-test.txt');
const server = http.createServer(common.mustCall(function(req, res) {
const stream = fs.createWriteStream(file);

View File

@ -7,14 +7,13 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
// Piping should work as expected with createWriteStream
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = path.join(tmpdir.path, 'http2-url-tests.js');
const fn = tmpdir.resolve('http2-url-tests.js');
const server = http2.createServer();

View File

@ -8,14 +8,13 @@ const assert = require('assert');
const http2 = require('http2');
const fs = require('fs');
const net = require('net');
const path = require('path');
// HTTP/2 servers can listen on a named pipe.
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = path.join(tmpdir.path, 'person-large.jpg');
const fn = tmpdir.resolve('person-large.jpg');
const server = http2.createServer();

View File

@ -7,14 +7,13 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
// Piping should work as expected with createWriteStream
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = path.join(tmpdir.path, 'http2-url-tests.js');
const fn = tmpdir.resolve('http2-url-tests.js');
const server = http2.createServer();

View File

@ -6,7 +6,6 @@ if (!common.hasCrypto)
if (common.isWindows)
common.skip('no mkfifo on Windows');
const child_process = require('child_process');
const path = require('path');
const fs = require('fs');
const http2 = require('http2');
const assert = require('assert');
@ -14,7 +13,7 @@ const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const pipeName = path.join(tmpdir.path, 'pipe');
const pipeName = tmpdir.resolve('pipe');
const mkfifo = child_process.spawnSync('mkfifo', [ pipeName ]);
if (mkfifo.error && mkfifo.error.code === 'ENOENT') {

View File

@ -6,7 +6,6 @@ if (!common.hasCrypto)
if (common.isWindows)
common.skip('no mkfifo on Windows');
const child_process = require('child_process');
const path = require('path');
const fs = require('fs');
const http2 = require('http2');
const assert = require('assert');
@ -14,7 +13,7 @@ const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const pipeName = path.join(tmpdir.path, 'pipe');
const pipeName = tmpdir.resolve('pipe');
const mkfifo = child_process.spawnSync('mkfifo', [ pipeName ]);
if (mkfifo.error && mkfifo.error.code === 'ENOENT') {

View File

@ -3,14 +3,13 @@
const common = require('../common');
const fs = require('fs');
const { once } = require('events');
const { join } = require('path');
const readline = require('readline');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const filename = join(tmpdir.path, 'test.txt');
const filename = tmpdir.resolve('test.txt');
const testContents = [
'',

View File

@ -2,7 +2,6 @@
const common = require('../common');
const fs = require('fs');
const { join } = require('path');
const readline = require('readline');
const { Readable } = require('stream');
const assert = require('assert');
@ -10,7 +9,7 @@ const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const filename = join(tmpdir.path, 'test.txt');
const filename = tmpdir.resolve('test.txt');
const testContents = [
'',

View File

@ -7,7 +7,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { inspect } = require('util');
common.skipIfDumbTerminal();
@ -17,7 +16,7 @@ tmpdir.refresh();
process.throwDeprecation = true;
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {

View File

@ -7,7 +7,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { inspect } = require('util');
common.skipIfDumbTerminal();
@ -18,7 +17,7 @@ tmpdir.refresh();
process.throwDeprecation = true;
process.on('warning', common.mustNotCall());
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {

View File

@ -13,7 +13,6 @@ if (common.isWindows) {
}
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const repl = require('internal/repl');
const Duplex = require('stream').Duplex;
@ -33,7 +32,7 @@ stream.readable = stream.writable = true;
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const replHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const replHistoryPath = tmpdir.resolve('.node_repl_history');
const checkResults = common.mustSucceed((r) => {
const stat = fs.statSync(replHistoryPath);

View File

@ -8,7 +8,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
const util = require('util');
@ -60,12 +59,11 @@ const CLEAR = { ctrl: true, name: 'u' };
// File paths
const historyFixturePath = fixtures.path('.node_repl_history');
const historyPath = path.join(tmpdir.path, '.fixture_copy_repl_history');
const historyPath = tmpdir.resolve('.fixture_copy_repl_history');
const historyPathFail = fixtures.path('nonexistent_folder', 'filename');
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
const emptyHiddenHistoryPath = fixtures.path('.empty-hidden-repl-history-file');
const devNullHistoryPath = path.join(tmpdir.path,
'.dev-null-repl-history-file');
const devNullHistoryPath = tmpdir.resolve('.dev-null-repl-history-file');
// Common message bits
const prompt = '> ';
const replDisabled = '\nPersistent history support disabled. Set the ' +

View File

@ -6,7 +6,6 @@ const stream = require('stream');
const REPL = require('repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
const util = require('util');
@ -58,12 +57,11 @@ const CLEAR = { ctrl: true, name: 'u' };
// File paths
const historyFixturePath = fixtures.path('.node_repl_history');
const historyPath = path.join(tmpdir.path, '.fixture_copy_repl_history');
const historyPath = tmpdir.resolve('.fixture_copy_repl_history');
const historyPathFail = fixtures.path('nonexistent_folder', 'filename');
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
const emptyHiddenHistoryPath = fixtures.path('.empty-hidden-repl-history-file');
const devNullHistoryPath = path.join(tmpdir.path,
'.dev-null-repl-history-file');
const devNullHistoryPath = tmpdir.resolve('.dev-null-repl-history-file');
// Common message bits
const prompt = '> ';
const replDisabled = '\nPersistent history support disabled. Set the ' +

View File

@ -4,11 +4,10 @@ const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const spawn = require('child_process').spawn;
const path = require('path');
tmpdir.refresh();
const requirePath = JSON.stringify(path.join(tmpdir.path, 'non-existent.json'));
const requirePath = JSON.stringify(tmpdir.resolve('non-existent.json'));
// Use -i to force node into interactive mode, despite stdout not being a TTY
const child = spawn(process.execPath, ['-i']);

View File

@ -7,7 +7,6 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { inspect } = require('util');
common.skipIfDumbTerminal();
@ -16,7 +15,7 @@ common.allowGlobals('aaaa');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
const defaultHistoryPath = tmpdir.resolve('.node_repl_history');
// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {

View File

@ -23,7 +23,6 @@
const common = require('../common');
const ArrayStream = require('../common/arraystream');
const assert = require('assert');
const join = require('path').join;
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
@ -48,7 +47,7 @@ const testFile = [
' return {one:1};',
'})()',
];
const saveFileName = join(tmpdir.path, 'test.save.js');
const saveFileName = tmpdir.resolve('test.save.js');
// Add some data.
putIn.run(testFile);
@ -79,7 +78,7 @@ testMe.complete('inner.o', common.mustSucceed((data) => {
// Clear the REPL.
putIn.run(['.clear']);
let loadFile = join(tmpdir.path, 'file.does.not.exist');
let loadFile = tmpdir.resolve('file.does.not.exist');
// Should not break.
putIn.write = common.mustCall(function(data) {
@ -103,7 +102,7 @@ putIn.run(['.clear']);
// NUL (\0) is disallowed in filenames in UNIX-like operating systems and
// Windows so we can use that to test failed saves.
const invalidFileName = join(tmpdir.path, '\0\0\0\0\0');
const invalidFileName = tmpdir.resolve('\0\0\0\0\0');
// Should not break.
putIn.write = common.mustCall(function(data) {

View File

@ -7,7 +7,6 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
const v8 = require('v8');
@ -17,7 +16,7 @@ const v8 = require('v8');
assert(!v8.startupSnapshot.isBuildingSnapshot());
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const entry = fixtures.path('snapshot', 'v8-startup-snapshot-api.js');
{
for (const book of [
@ -26,9 +25,9 @@ const entry = fixtures.path('snapshot', 'v8-startup-snapshot-api.js');
'book2.zh_CN.txt',
]) {
const content = `This is ${book}`;
fs.writeFileSync(path.join(tmpdir.path, book), content, 'utf8');
fs.writeFileSync(tmpdir.resolve(book), content, 'utf8');
}
fs.copyFileSync(entry, path.join(tmpdir.path, 'entry.js'));
fs.copyFileSync(entry, tmpdir.resolve('entry.js'));
const child = spawnSync(process.execPath, [
'--snapshot-blob',
blobPath,
@ -42,7 +41,7 @@ const entry = fixtures.path('snapshot', 'v8-startup-snapshot-api.js');
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -6,18 +6,17 @@ require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const code = `
require('v8').startupSnapshot.setDeserializeMainFunction(() => {
console.log(JSON.stringify(process.argv));
});
`;
{
fs.writeFileSync(path.join(tmpdir.path, 'entry.js'), code, 'utf8');
fs.writeFileSync(tmpdir.resolve('entry.js'), code, 'utf8');
const child = spawnSync(process.execPath, [
'--snapshot-blob',
blobPath,
@ -31,7 +30,7 @@ require('v8').startupSnapshot.setDeserializeMainFunction(() => {
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -8,7 +8,6 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
@ -48,12 +47,12 @@ if (!process.config.variables.node_use_node_snapshot) {
console.log(child.signal);
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'my-snapshot.blob');
const blobPath = tmpdir.resolve('my-snapshot.blob');
{
// Create the snapshot.
const child = spawnSync(process.execPath, [

View File

@ -8,11 +8,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const file = fixtures.path('snapshot', 'mutate-fs.js');
const checkFile = fixtures.path('snapshot', 'check-mutate-fs.js');

View File

@ -9,11 +9,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const entry = fixtures.path('snapshot', 'console.js');
{
@ -32,7 +31,7 @@ const entry = fixtures.path('snapshot', 'console.js');
assert.strictEqual(child.status, 0);
}
assert.deepStrictEqual(Object.keys(console), JSON.parse(stdout));
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -8,11 +8,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const entry = fixtures.path('snapshot', 'error.js');
// --build-snapshot should be run with an entry point.
@ -31,7 +30,7 @@ const entry = fixtures.path('snapshot', 'error.js');
assert.strictEqual(child.status, 9);
assert.match(stderr,
/--build-snapshot must be used with an entry point script/);
assert(!fs.existsSync(path.join(tmpdir.path, 'snapshot.blob')));
assert(!fs.existsSync(tmpdir.resolve('snapshot.blob')));
}
// Loading a non-existent snapshot should fail.
@ -49,7 +48,7 @@ const entry = fixtures.path('snapshot', 'error.js');
console.log(child.stdout.toString());
assert.strictEqual(child.status, 14);
assert.match(stderr, /Cannot open/);
assert(!fs.existsSync(path.join(tmpdir.path, 'snapshot.blob')));
assert(!fs.existsSync(tmpdir.resolve('snapshot.blob')));
}
@ -69,5 +68,5 @@ const entry = fixtures.path('snapshot', 'error.js');
console.log(child.stdout.toString());
assert.strictEqual(child.status, 1);
assert.match(stderr, /error\.js:1/);
assert(!fs.existsSync(path.join(tmpdir.path, 'snapshot.blob')));
assert(!fs.existsSync(tmpdir.resolve('snapshot.blob')));
}

View File

@ -8,11 +8,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const file = fixtures.path('snapshot', 'mutate-fs.js');
{

View File

@ -8,11 +8,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const file = fixtures.path('snapshot', 'decompress-gzip-sync.js');
{
@ -36,7 +35,7 @@ const file = fixtures.path('snapshot', 'decompress-gzip-sync.js');
console.log(stdout);
assert.strictEqual(child.status, 0);
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
assert(stdout.includes('NODE_TEST_MODE: snapshot'));
}

View File

@ -8,11 +8,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const entry = fixtures.path('empty.js');
// The flag used can be any flag that makes a difference in
@ -34,7 +33,7 @@ const entry = fixtures.path('empty.js');
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -6,11 +6,10 @@ require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
{
// The list of modules supported in the snapshot is unstable, so just check
// a few that are known to work.
@ -20,7 +19,7 @@ const blobPath = path.join(tmpdir.path, 'snapshot.blob');
require("node:fs/promises");
`;
fs.writeFileSync(
path.join(tmpdir.path, 'entry.js'),
tmpdir.resolve('entry.js'),
code,
'utf8'
);
@ -37,6 +36,6 @@ const blobPath = path.join(tmpdir.path, 'snapshot.blob');
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -8,11 +8,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const entry = fixtures.path('snapshot', 'server.js');
{
const child = spawnSync(process.execPath, [
@ -28,7 +27,7 @@ const entry = fixtures.path('snapshot', 'server.js');
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -8,16 +8,15 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
// Concat test/fixtures/snapshot/typescript.js with
// test/fixtures/snapshot/typescript.js into
// tmpdir/snapshot.js.
const file = path.join(tmpdir.path, 'snapshot.js');
const file = tmpdir.resolve('snapshot.js');
fs.copyFileSync(fixtures.path('snapshot', 'typescript.js'), file);
fs.appendFileSync(file,
fs.readFileSync(fixtures.path('snapshot', 'typescript-main.js')));
@ -37,12 +36,12 @@ fs.appendFileSync(file,
console.log(stdout);
assert.strictEqual(child.status, 0);
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}
{
const outPath = path.join(tmpdir.path, 'ts-example.js');
const outPath = tmpdir.resolve('ts-example.js');
const child = spawnSync(process.execPath, [
'--snapshot-blob',
blobPath,

View File

@ -7,11 +7,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const file = fixtures.path('snapshot', 'marked.js');
{
@ -30,14 +29,14 @@ const file = fixtures.path('snapshot', 'marked.js');
console.log(stdout);
assert.strictEqual(child.status, 0);
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}
{
let child = spawnSync(process.execPath, [
'--snapshot-blob',
path.join(tmpdir.path, 'snapshot.blob'),
tmpdir.resolve('snapshot.blob'),
fixtures.path('snapshot', 'check-marked.js'),
], {
cwd: tmpdir.path,

View File

@ -10,11 +10,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
const warningScript = fixtures.path('snapshot', 'warning.js');
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const empty = fixtures.path('empty.js');
tmpdir.refresh();
@ -102,8 +101,8 @@ tmpdir.refresh();
tmpdir.refresh();
{
console.log('\n# Check --redirect-warnings');
const warningFile1 = path.join(tmpdir.path, 'warnings.txt');
const warningFile2 = path.join(tmpdir.path, 'warnings2.txt');
const warningFile1 = tmpdir.resolve('warnings.txt');
const warningFile2 = tmpdir.resolve('warnings2.txt');
let child = spawnSync(process.execPath, [
'--snapshot-blob',

View File

@ -7,11 +7,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
function runTest(entry) {
console.log('running test with', entry);
@ -31,7 +30,7 @@ function runTest(entry) {
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
assert(stats.isFile());
}

View File

@ -7,11 +7,10 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');
tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const blobPath = tmpdir.resolve('snapshot.blob');
const entry = fixtures.path('snapshot', 'worker.js');
{
const child = spawnSync(process.execPath, [

View File

@ -3,14 +3,13 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled', '-e', CODE ],

View File

@ -12,7 +12,6 @@ try {
const assert = require('assert');
const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
const {
@ -147,7 +146,7 @@ function testApiInChildProcess(execArgs, cb) {
});
proc.once('exit', common.mustCall(() => {
const file = path.join(tmpdir.path, 'node_trace.1.log');
const file = tmpdir.resolve('node_trace.1.log');
assert(fs.existsSync(file));
fs.readFile(file, common.mustSucceed((data) => {

View File

@ -13,7 +13,6 @@ try {
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const enable = `require("trace_events").createTracing(
{ categories: ["node.async_hooks"] }).enable();`;
@ -21,7 +20,7 @@ const code =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
const tmpdir = require('../common/tmpdir');
const filename = path.join(tmpdir.path, 'node_trace.1.log');
const filename = tmpdir.resolve('node_trace.1.log');
tmpdir.refresh();
const proc = cp.spawnSync(

View File

@ -13,7 +13,6 @@ try {
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const code =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
@ -28,7 +27,7 @@ worker.stderr.on('data',
worker.on('exit', () => { ${code} })`;
const tmpdir = require('../common/tmpdir');
const filename = path.join(tmpdir.path, 'node_trace.1.log');
const filename = tmpdir.resolve('node_trace.1.log');
tmpdir.refresh();
const proc = cp.spawnSync(

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const util = require('util');
const CODE =
@ -11,7 +10,7 @@ const CODE =
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'node.async_hooks',

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const CODE = `
const { internalBinding } = require('internal/test/binding');
@ -19,7 +18,7 @@ const CODE = `
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'custom',

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const names = [
@ -30,7 +29,7 @@ if (process.argv[2] === 'child') {
});
proc.once('exit', common.mustCall(() => {
const file = path.join(tmpdir.path, 'node_trace.1.log');
const file = tmpdir.resolve('node_trace.1.log');
assert(fs.existsSync(file));
fs.readFile(file, common.mustCall((err, data) => {

View File

@ -2,7 +2,6 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
@ -42,7 +41,7 @@ if (process.argv[2] === 'child') {
});
proc.once('exit', common.mustCall(async () => {
const file = path.join(tmpdir.path, 'node_trace.1.log');
const file = tmpdir.resolve('node_trace.1.log');
assert(fs.existsSync(file));
const data = await fs.promises.readFile(file, { encoding: 'utf8' });

View File

@ -4,7 +4,6 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
@ -42,7 +41,7 @@ if (process.argv[2] === 'child') {
});
proc.once('exit', common.mustCall(async () => {
const file = path.join(tmpdir.path, 'node_trace.1.log');
const file = tmpdir.resolve('node_trace.1.log');
const checkSet = new Set();
assert(fs.existsSync(file));

View File

@ -4,7 +4,6 @@ const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
tmpdir.refresh();
@ -20,8 +19,7 @@ const proc = cp.spawn(process.execPath, [
], { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
const expectedFilename = path.join(tmpdir.path,
`${proc.pid}-1-${proc.pid}-1.tracing.log`);
const expectedFilename = tmpdir.resolve(`${proc.pid}-1-${proc.pid}-1.tracing.log`);
assert(fs.existsSync(expectedFilename));
fs.readFile(expectedFilename, common.mustCall((err, data) => {

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const util = require('util');
const tests = { __proto__: null };
@ -305,7 +304,7 @@ if (common.canCreateSymLink()) {
}
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const traceFile = path.join(tmpdir.path, 'node_trace.1.log');
const traceFile = tmpdir.resolve('node_trace.1.log');
for (const tr in tests) {
const proc = cp.spawnSync(process.execPath,

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const util = require('util');
const tests = { __proto__: null };
@ -116,7 +115,7 @@ if (common.canCreateSymLink()) {
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const traceFile = path.join(tmpdir.path, 'node_trace.1.log');
const traceFile = tmpdir.resolve('node_trace.1.log');
for (const tr in tests) {
const proc = cp.spawnSync(process.execPath,

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const CODE = `
@ -17,7 +16,7 @@ const CODE = `
`;
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1);' +
@ -11,7 +10,7 @@ const CODE =
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'node.perf.usertiming',

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const CODE = `
@ -19,7 +18,7 @@ const CODE = `
`;
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',

View File

@ -3,14 +3,13 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc_no_categories = cp.spawn(
process.execPath,

View File

@ -3,11 +3,10 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
if (process.argv[2] === 'child') {
@ -26,7 +25,7 @@ if (process.argv[2] === 'child') {
});
proc.once('exit', common.mustCall(() => {
const file = path.join(tmpdir.path, 'node_trace.1.log');
const file = tmpdir.resolve('node_trace.1.log');
assert(fs.existsSync(file));
fs.readFile(file, common.mustCall((err, data) => {

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const { scheduler } = require('timers/promises');
@ -21,7 +20,7 @@ if (process.env.isChild === '1') {
}
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
cp.spawnSync(process.execPath,
[

View File

@ -3,14 +3,13 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',

View File

@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const names = [
@ -27,7 +26,7 @@ if (process.argv[2] === 'child') {
});
proc.once('exit', common.mustCall(() => {
const file = path.join(tmpdir.path, 'node_trace.1.log');
const file = tmpdir.resolve('node_trace.1.log');
assert(fs.existsSync(file));
fs.readFile(file, common.mustCall((err, data) => {