mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
test: use tmpdir.resolve()
PR-URL: https://github.com/nodejs/node/pull/49136 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
484ad83358
commit
052434a0c1
49 changed files with 97 additions and 118 deletions
|
@ -16,7 +16,7 @@ const tmpdir = require('../../common/tmpdir');
|
|||
tmpdir.refresh();
|
||||
|
||||
const addonPath = path.join(__dirname, 'build', common.buildType);
|
||||
const addonLink = path.join(tmpdir.path, 'addon');
|
||||
const addonLink = tmpdir.resolve('addon');
|
||||
|
||||
try {
|
||||
fs.symlinkSync(addonPath, addonLink, 'dir');
|
||||
|
|
|
@ -6,15 +6,14 @@ const assert = require('assert');
|
|||
const initHooks = require('./init-hooks');
|
||||
const { checkInvocations } = require('./hook-checks');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
if (!common.isMainThread)
|
||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
const file1 = path.join(tmpdir.path, 'file1');
|
||||
const file2 = path.join(tmpdir.path, 'file2');
|
||||
const file1 = tmpdir.resolve('file1');
|
||||
const file2 = tmpdir.resolve('file2');
|
||||
|
||||
const onchangex = (x) => (curr, prev) => {
|
||||
console.log(`Watcher: ${x}`);
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { spawnSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
|
||||
function buildSnapshot(entry, env) {
|
||||
const child = spawnSync(process.execPath, [
|
||||
'--snapshot-blob',
|
||||
path.join(tmpdir.path, 'snapshot.blob'),
|
||||
tmpdir.resolve('snapshot.blob'),
|
||||
'--build-snapshot',
|
||||
entry,
|
||||
], {
|
||||
|
@ -29,14 +28,14 @@ function buildSnapshot(entry, env) {
|
|||
|
||||
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());
|
||||
|
||||
return { child, stderr, stdout };
|
||||
}
|
||||
|
||||
function runWithSnapshot(entry, env) {
|
||||
const args = ['--snapshot-blob', path.join(tmpdir.path, 'snapshot.blob')];
|
||||
const args = ['--snapshot-blob', tmpdir.resolve('snapshot.blob')];
|
||||
if (entry !== undefined) {
|
||||
args.push(entry);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ fs.readdirSync(apilinks).forEach((fixture) => {
|
|||
const input = path.join(apilinks, fixture);
|
||||
|
||||
const expectedContent = fs.readFileSync(`${input}on`, 'utf8');
|
||||
const outputPath = path.join(tmpdir.path, `${fixture}on`);
|
||||
const outputPath = tmpdir.resolve(`${fixture}on`);
|
||||
execFileSync(
|
||||
process.execPath,
|
||||
[script, outputPath, input],
|
||||
|
|
|
@ -4,7 +4,6 @@ import tmpdir from '../common/tmpdir.js';
|
|||
import assert from 'assert';
|
||||
import { spawnSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import util from 'util';
|
||||
|
||||
|
@ -29,7 +28,7 @@ const expected = [
|
|||
];
|
||||
|
||||
tmpdir.refresh();
|
||||
const versionsFile = path.join(tmpdir.path, 'versions.json');
|
||||
const versionsFile = tmpdir.resolve('versions.json');
|
||||
debuglog(`${process.execPath} ${versionsTool} ${versionsFile}`);
|
||||
const opts = { cwd: tmpdir.path, encoding: 'utf8' };
|
||||
const cp = spawnSync(process.execPath, [ versionsTool, versionsFile ], opts);
|
||||
|
|
|
@ -63,7 +63,7 @@ function getReadFileCodeForPath(path) {
|
|||
for (const extraSnapshotArgs of [[], ['--embedder-snapshot-as-file']]) {
|
||||
// readSync + eval since snapshots don't support userland require() (yet)
|
||||
const snapshotFixture = fixtures.path('snapshot', 'echo-args.js');
|
||||
const blobPath = path.join(tmpdir.path, 'embedder-snapshot.blob');
|
||||
const blobPath = tmpdir.resolve('embedder-snapshot.blob');
|
||||
const buildSnapshotArgs = [
|
||||
`eval(${getReadFileCodeForPath(snapshotFixture)})`, 'arg1', 'arg2',
|
||||
'--embedder-snapshot-blob', blobPath, '--embedder-snapshot-create',
|
||||
|
@ -94,7 +94,7 @@ for (const extraSnapshotArgs of [[], ['--embedder-snapshot-as-file']]) {
|
|||
// Create workers and vm contexts after deserialization
|
||||
{
|
||||
const snapshotFixture = fixtures.path('snapshot', 'create-worker-and-vm.js');
|
||||
const blobPath = path.join(tmpdir.path, 'embedder-snapshot.blob');
|
||||
const blobPath = tmpdir.resolve('embedder-snapshot.blob');
|
||||
const buildSnapshotArgs = [
|
||||
`eval(${getReadFileCodeForPath(snapshotFixture)})`,
|
||||
'--embedder-snapshot-blob', blobPath, '--embedder-snapshot-create',
|
||||
|
|
|
@ -11,7 +11,7 @@ describe('ESM in main field', { concurrency: true }, () => {
|
|||
before(() => tmpdir.refresh());
|
||||
|
||||
it('should handle fully-specified relative path without any warning', async () => {
|
||||
const cwd = path.join(tmpdir.path, Math.random().toString());
|
||||
const cwd = tmpdir.resolve(Math.random().toString());
|
||||
const pkgPath = path.join(cwd, './node_modules/pkg/');
|
||||
await mkdir(pkgPath, { recursive: true });
|
||||
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
|
||||
|
@ -29,7 +29,7 @@ describe('ESM in main field', { concurrency: true }, () => {
|
|||
assert.strictEqual(code, 0);
|
||||
});
|
||||
it('should handle fully-specified absolute path without any warning', async () => {
|
||||
const cwd = path.join(tmpdir.path, Math.random().toString());
|
||||
const cwd = tmpdir.resolve(Math.random().toString());
|
||||
const pkgPath = path.join(cwd, './node_modules/pkg/');
|
||||
await mkdir(pkgPath, { recursive: true });
|
||||
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
|
||||
|
@ -48,7 +48,7 @@ describe('ESM in main field', { concurrency: true }, () => {
|
|||
});
|
||||
|
||||
it('should emit warning when "main" and "exports" are missing', async () => {
|
||||
const cwd = path.join(tmpdir.path, Math.random().toString());
|
||||
const cwd = tmpdir.resolve(Math.random().toString());
|
||||
const pkgPath = path.join(cwd, './node_modules/pkg/');
|
||||
await mkdir(pkgPath, { recursive: true });
|
||||
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
|
||||
|
@ -65,7 +65,7 @@ describe('ESM in main field', { concurrency: true }, () => {
|
|||
assert.strictEqual(code, 0);
|
||||
});
|
||||
it('should emit warning when "main" is falsy', async () => {
|
||||
const cwd = path.join(tmpdir.path, Math.random().toString());
|
||||
const cwd = tmpdir.resolve(Math.random().toString());
|
||||
const pkgPath = path.join(cwd, './node_modules/pkg/');
|
||||
await mkdir(pkgPath, { recursive: true });
|
||||
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
|
||||
|
@ -83,7 +83,7 @@ describe('ESM in main field', { concurrency: true }, () => {
|
|||
assert.strictEqual(code, 0);
|
||||
});
|
||||
it('should emit warning when "main" is a relative path without extension', async () => {
|
||||
const cwd = path.join(tmpdir.path, Math.random().toString());
|
||||
const cwd = tmpdir.resolve(Math.random().toString());
|
||||
const pkgPath = path.join(cwd, './node_modules/pkg/');
|
||||
await mkdir(pkgPath, { recursive: true });
|
||||
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
|
||||
|
@ -101,7 +101,7 @@ describe('ESM in main field', { concurrency: true }, () => {
|
|||
assert.strictEqual(code, 0);
|
||||
});
|
||||
it('should emit warning when "main" is an absolute path without extension', async () => {
|
||||
const cwd = path.join(tmpdir.path, Math.random().toString());
|
||||
const cwd = tmpdir.resolve(Math.random().toString());
|
||||
const pkgPath = path.join(cwd, './node_modules/pkg/');
|
||||
await mkdir(pkgPath, { recursive: true });
|
||||
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
|
||||
|
|
|
@ -26,7 +26,7 @@ const {
|
|||
defaultResolve: resolve
|
||||
} = internalResolve;
|
||||
|
||||
const rel = (file) => path.join(tmpdir.path, file);
|
||||
const rel = (file) => tmpdir.resolve(file);
|
||||
const previousCwd = process.cwd();
|
||||
const nmDir = rel('node_modules');
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ const fs = require('fs');
|
|||
tmpdir.refresh();
|
||||
|
||||
const realPath = path.resolve(__dirname, '../fixtures/es-modules/symlink.mjs');
|
||||
const symlinkPath = path.resolve(tmpdir.path, 'symlink.mjs');
|
||||
const symlinkPath = tmpdir.resolve('symlink.mjs');
|
||||
|
||||
try {
|
||||
fs.symlinkSync(realPath, symlinkPath);
|
||||
|
|
|
@ -15,7 +15,7 @@ const imp = (file) => {
|
|||
|
||||
(async () => {
|
||||
tmpdir.refresh();
|
||||
const rel = (file) => path.join(tmpdir.path, file);
|
||||
const rel = (file) => tmpdir.resolve(file);
|
||||
|
||||
{ // Load a single script
|
||||
const file = rel('con.mjs');
|
||||
|
|
4
test/fixtures/test-runner/concurrency/a.mjs
vendored
4
test/fixtures/test-runner/concurrency/a.mjs
vendored
|
@ -3,9 +3,9 @@ import { setTimeout } from 'node:timers/promises';
|
|||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
await fs.writeFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'a.mjs');
|
||||
await fs.writeFile(tmpdir.resolve('test-runner-concurrency'), 'a.mjs');
|
||||
while (true) {
|
||||
const file = await fs.readFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'utf8');
|
||||
const file = await fs.readFile(tmpdir.resolve('test-runner-concurrency'), 'utf8');
|
||||
if (file === 'b.mjs') {
|
||||
break;
|
||||
}
|
||||
|
|
4
test/fixtures/test-runner/concurrency/b.mjs
vendored
4
test/fixtures/test-runner/concurrency/b.mjs
vendored
|
@ -4,9 +4,9 @@ import fs from 'node:fs/promises';
|
|||
import path from 'node:path';
|
||||
|
||||
while (true) {
|
||||
const file = await fs.readFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'utf8');
|
||||
const file = await fs.readFile(tmpdir.resolve('test-runner-concurrency'), 'utf8');
|
||||
if (file === 'a.mjs') {
|
||||
await fs.writeFile(path.resolve(tmpdir.path, 'test-runner-concurrency'), 'b.mjs');
|
||||
await fs.writeFile(tmpdir.resolve('test-runner-concurrency'), 'b.mjs');
|
||||
break;
|
||||
}
|
||||
await setTimeout(10);
|
||||
|
|
2
test/fixtures/watch-mode/ipc.js
vendored
2
test/fixtures/watch-mode/ipc.js
vendored
|
@ -3,7 +3,7 @@ const url = require('node:url');
|
|||
const fs = require('node:fs');
|
||||
const tmpdir = require('../../common/tmpdir');
|
||||
|
||||
const tmpfile = path.join(tmpdir.path, 'file');
|
||||
const tmpfile = tmpdir.resolve('file');
|
||||
fs.writeFileSync(tmpfile, '');
|
||||
|
||||
process.send({ 'watch:require': [path.resolve(__filename)] });
|
||||
|
|
|
@ -11,11 +11,11 @@ const fixtures = require('../common/fixtures');
|
|||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const npmSandbox = path.join(tmpdir.path, 'npm-sandbox');
|
||||
const npmSandbox = tmpdir.resolve('npm-sandbox');
|
||||
fs.mkdirSync(npmSandbox);
|
||||
const homeDir = path.join(tmpdir.path, 'home');
|
||||
const homeDir = tmpdir.resolve('home');
|
||||
fs.mkdirSync(homeDir);
|
||||
const installDir = path.join(tmpdir.path, 'install-dir');
|
||||
const installDir = tmpdir.resolve('install-dir');
|
||||
fs.mkdirSync(installDir);
|
||||
|
||||
const corepackYarnPath = path.join(
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
|
@ -57,7 +56,7 @@ for (const tr in tests) {
|
|||
throw new Error(`${tr}:\n${util.inspect(proc)}`);
|
||||
}
|
||||
|
||||
const file = path.join(tmpdir.path, traceFile);
|
||||
const file = tmpdir.resolve(traceFile);
|
||||
|
||||
const data = fs.readFileSync(file);
|
||||
const traces = JSON.parse(data.toString()).traceEvents
|
||||
|
|
|
@ -19,7 +19,7 @@ tmpdir.refresh();
|
|||
}
|
||||
|
||||
{
|
||||
const urlTestDir = path.join(tmpdir.path, 'foo%#bar');
|
||||
const urlTestDir = tmpdir.resolve('foo%#bar');
|
||||
const urlTestFile = path.join(urlTestDir, path.basename(filename));
|
||||
fs.mkdirSync(urlTestDir, { recursive: true });
|
||||
fs.copyFileSync(filename, urlTestFile);
|
||||
|
|
|
@ -8,7 +8,6 @@ const tmpdir = require('../../common/tmpdir');
|
|||
const { spawnSync } = require('child_process');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { pathToFileURL } = require('url');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
@ -19,7 +18,7 @@ function hash(algo, body) {
|
|||
return h.digest('base64');
|
||||
}
|
||||
|
||||
const policyFilepath = path.join(tmpdir.path, 'policy');
|
||||
const policyFilepath = tmpdir.resolve('policy');
|
||||
|
||||
const depFilepath = require.resolve(`./build/${common.buildType}/binding.node`);
|
||||
const depURL = pathToFileURL(depFilepath);
|
||||
|
|
|
@ -24,14 +24,13 @@ const common = require('../common');
|
|||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
try {
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'large.txt');
|
||||
const filepath = tmpdir.resolve('large.txt');
|
||||
const fd = fs.openSync(filepath, 'w+');
|
||||
const offset = 5 * 1024 * 1024 * 1024; // 5GB
|
||||
const message = 'Large File';
|
||||
|
|
|
@ -7,7 +7,6 @@ if (!common.enoughTestMem)
|
|||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cp = require('child_process');
|
||||
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
|
||||
if (common.isAIX && (Number(cp.execSync('ulimit -f')) * 512) < kStringMaxLength)
|
||||
|
@ -20,7 +19,7 @@ if (!tmpdir.hasEnoughSpace(kStringMaxLength)) {
|
|||
common.skip(`Not enough space in ${tmpdir.path}`);
|
||||
}
|
||||
|
||||
const file = path.join(tmpdir.path, 'toobig.txt');
|
||||
const file = tmpdir.resolve('toobig.txt');
|
||||
const stream = fs.createWriteStream(file, {
|
||||
flags: 'a',
|
||||
});
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
tmpdir.refresh();
|
||||
const FILENAME = path.join(tmpdir.path, 'watch-me');
|
||||
const FILENAME = tmpdir.resolve('watch-me');
|
||||
const TIMEOUT = 1300;
|
||||
|
||||
let nevents = 0;
|
||||
|
|
|
@ -194,7 +194,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -194,7 +194,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -194,7 +194,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -194,7 +194,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -211,7 +211,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -211,7 +211,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -211,7 +211,7 @@ function drainQueue() {
|
|||
assert.notStrictEqual(status, 0, 'Should not allow multiple policies');
|
||||
}
|
||||
{
|
||||
const enoentFilepath = path.join(tmpdir.path, 'enoent');
|
||||
const enoentFilepath = tmpdir.resolve('enoent');
|
||||
try {
|
||||
fs.unlinkSync(enoentFilepath);
|
||||
} catch {
|
||||
|
|
|
@ -24,11 +24,10 @@
|
|||
require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
tmpdir.refresh();
|
||||
const f = path.join(tmpdir.path, 'x.txt');
|
||||
const f = tmpdir.resolve('x.txt');
|
||||
fs.closeSync(fs.openSync(f, 'w'));
|
||||
|
||||
let changes = 0;
|
||||
|
|
|
@ -50,7 +50,7 @@ function validate() {
|
|||
{
|
||||
// Test with a file argument.
|
||||
const file = process.report.writeReport('custom-name-1.json');
|
||||
const absolutePath = path.join(tmpdir.path, file);
|
||||
const absolutePath = tmpdir.resolve(file);
|
||||
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
|
||||
assert.strictEqual(file, 'custom-name-1.json');
|
||||
helper.validate(absolutePath);
|
||||
|
@ -61,7 +61,7 @@ function validate() {
|
|||
// Test with file and error arguments.
|
||||
const file = process.report.writeReport('custom-name-2.json',
|
||||
new Error('test error'));
|
||||
const absolutePath = path.join(tmpdir.path, file);
|
||||
const absolutePath = tmpdir.resolve(file);
|
||||
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
|
||||
assert.strictEqual(file, 'custom-name-2.json');
|
||||
helper.validate(absolutePath);
|
||||
|
@ -117,7 +117,7 @@ function validate() {
|
|||
|
||||
{
|
||||
// Test the case where the report file cannot be opened.
|
||||
const reportDir = path.join(tmpdir.path, 'does', 'not', 'exist');
|
||||
const reportDir = tmpdir.resolve('does', 'not', 'exist');
|
||||
const args = [`--report-directory=${reportDir}`,
|
||||
'-e',
|
||||
'process.report.writeReport()'];
|
||||
|
|
|
@ -8,7 +8,6 @@ common.skipIfInspectorDisabled();
|
|||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
@ -22,7 +21,7 @@ const {
|
|||
// relative --cpu-prof-dir
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--cpu-prof',
|
||||
'--cpu-prof-interval',
|
||||
|
|
|
@ -21,7 +21,7 @@ const {
|
|||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
const file = path.join(dir, 'test.cpuprofile');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--cpu-prof',
|
||||
|
|
|
@ -8,7 +8,6 @@ common.skipIfInspectorDisabled();
|
|||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
@ -37,7 +36,7 @@ const {
|
|||
console.log(output.stderr.toString());
|
||||
}
|
||||
assert.strictEqual(output.status, 0);
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
assert(fs.existsSync(dir));
|
||||
const profiles = getCpuProfiles(dir);
|
||||
assert.strictEqual(profiles.length, 1);
|
||||
|
|
|
@ -8,7 +8,6 @@ common.skipIfInspectorDisabled();
|
|||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
@ -37,7 +36,7 @@ const {
|
|||
console.log(output.stderr.toString());
|
||||
}
|
||||
assert.strictEqual(output.status, 0);
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
assert(fs.existsSync(dir));
|
||||
const profiles = getCpuProfiles(dir);
|
||||
assert.strictEqual(profiles.length, 2);
|
||||
|
|
|
@ -8,7 +8,6 @@ const fixtures = require('../common/fixtures');
|
|||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
@ -22,7 +21,7 @@ const {
|
|||
// --cpu-prof-name
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const file = path.join(tmpdir.path, 'test.cpuprofile');
|
||||
const file = tmpdir.resolve('test.cpuprofile');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--cpu-prof',
|
||||
'--cpu-prof-interval',
|
||||
|
|
|
@ -9,7 +9,6 @@ common.skipIfInspectorDisabled();
|
|||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
@ -24,7 +23,7 @@ const {
|
|||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--cpu-prof',
|
||||
'--cpu-prof-interval',
|
||||
|
@ -50,8 +49,8 @@ const {
|
|||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'diag');
|
||||
const dir2 = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('diag');
|
||||
const dir2 = tmpdir.resolve('prof');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--cpu-prof',
|
||||
'--cpu-prof-interval',
|
||||
|
|
|
@ -66,7 +66,7 @@ function getHeapProfiles(dir) {
|
|||
// Test --diagnostic-dir changes the default for --cpu-prof
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('prof');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--heap-prof',
|
||||
'--diagnostic-dir',
|
||||
|
@ -91,8 +91,8 @@ function getHeapProfiles(dir) {
|
|||
// Test --heap-prof-dir overwrites --diagnostic-dir
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = path.join(tmpdir.path, 'diag');
|
||||
const dir2 = path.join(tmpdir.path, 'prof');
|
||||
const dir = tmpdir.resolve('diag');
|
||||
const dir2 = tmpdir.resolve('prof');
|
||||
const output = spawnSync(process.execPath, [
|
||||
'--heap-prof',
|
||||
'--heap-prof-interval',
|
||||
|
|
|
@ -6,7 +6,6 @@ const assert = require('assert');
|
|||
const fixtures = require('../common/fixtures');
|
||||
const fs = require('fs');
|
||||
const http2 = require('http2');
|
||||
const path = require('path');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
@ -30,7 +29,7 @@ let offsetTimeout = common.platformTimeout(100);
|
|||
let didReceiveData = false;
|
||||
|
||||
const content = Buffer.alloc(writeSize, 0x44);
|
||||
const filepath = path.join(tmpdir.path, 'http2-large-write.tmp');
|
||||
const filepath = tmpdir.resolve('http2-large-write.tmp');
|
||||
fs.writeFileSync(filepath, content, 'binary');
|
||||
const fd = fs.openSync(filepath, 'r');
|
||||
process.on('beforeExit', () => fs.closeSync(fd));
|
||||
|
|
|
@ -21,10 +21,10 @@ const { strictEqual } = require('assert');
|
|||
const assert = require('assert');
|
||||
|
||||
const inputFile = fixtures.path('sea.js');
|
||||
const requirableFile = join(tmpdir.path, 'requirable.js');
|
||||
const configFile = join(tmpdir.path, 'sea-config.json');
|
||||
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
||||
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const requirableFile = tmpdir.resolve('requirable.js');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
|
@ -43,7 +43,7 @@ writeFileSync(configFile, `
|
|||
`);
|
||||
|
||||
// Copy input to working directory
|
||||
copyFileSync(inputFile, join(tmpdir.path, 'sea.js'));
|
||||
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
||||
execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], {
|
||||
cwd: tmpdir.path
|
||||
});
|
||||
|
|
|
@ -15,16 +15,15 @@ skipIfSingleExecutableIsNotSupported();
|
|||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { execFileSync } = require('child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = join(tmpdir.path, 'sea-config.json');
|
||||
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
||||
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
writeFileSync(join(tmpdir.path, 'empty.js'), '', 'utf-8');
|
||||
writeFileSync(tmpdir.resolve('empty.js'), '', 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "empty.js",
|
||||
|
|
|
@ -14,17 +14,16 @@ skipIfSingleExecutableIsNotSupported();
|
|||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSync } = require('child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = join(tmpdir.path, 'sea-config.json');
|
||||
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
||||
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
|
||||
writeFileSync(join(tmpdir.path, 'snapshot.js'), '', 'utf-8');
|
||||
writeFileSync(tmpdir.resolve('snapshot.js'), '', 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
|
@ -57,7 +56,7 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' :
|
|||
});
|
||||
`;
|
||||
|
||||
writeFileSync(join(tmpdir.path, 'snapshot.js'), code, 'utf-8');
|
||||
writeFileSync(tmpdir.resolve('snapshot.js'), code, 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
|
|
|
@ -21,10 +21,10 @@ const { strictEqual } = require('assert');
|
|||
const assert = require('assert');
|
||||
|
||||
const inputFile = fixtures.path('sea.js');
|
||||
const requirableFile = join(tmpdir.path, 'requirable.js');
|
||||
const configFile = join(tmpdir.path, 'sea-config.json');
|
||||
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
||||
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const requirableFile = tmpdir.resolve('requirable.js');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
|
@ -43,7 +43,7 @@ writeFileSync(configFile, `
|
|||
`);
|
||||
|
||||
// Copy input to working directory
|
||||
copyFileSync(inputFile, join(tmpdir.path, 'sea.js'));
|
||||
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
||||
execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], {
|
||||
cwd: tmpdir.path
|
||||
});
|
||||
|
|
|
@ -20,10 +20,10 @@ const { strictEqual } = require('assert');
|
|||
const assert = require('assert');
|
||||
|
||||
const inputFile = fixtures.path('sea.js');
|
||||
const requirableFile = join(tmpdir.path, 'requirable.js');
|
||||
const configFile = join(tmpdir.path, 'sea-config.json');
|
||||
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
||||
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const requirableFile = tmpdir.resolve('requirable.js');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
|
@ -42,7 +42,7 @@ writeFileSync(configFile, `
|
|||
`);
|
||||
|
||||
// Copy input to working directory
|
||||
copyFileSync(inputFile, join(tmpdir.path, 'sea.js'));
|
||||
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
||||
execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], {
|
||||
cwd: tmpdir.path
|
||||
});
|
||||
|
|
|
@ -45,7 +45,6 @@ function doTest() {
|
|||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
const fs = require('fs');
|
||||
const join = require('path').join;
|
||||
const fixtures = require('../common/fixtures');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
|
@ -69,7 +68,7 @@ function doTest() {
|
|||
|
||||
const sessionFileName = (function() {
|
||||
const ticketFileName = 'tls-session-ticket.txt';
|
||||
const tmpPath = join(tmpdir.path, ticketFileName);
|
||||
const tmpPath = tmpdir.resolve(ticketFileName);
|
||||
fs.writeFileSync(tmpPath, fixtures.readSync(ticketFileName));
|
||||
return tmpPath;
|
||||
}());
|
||||
|
|
|
@ -117,7 +117,7 @@ describe('watch mode', { concurrency: true, timeout: 60_000 }, () => {
|
|||
it('should watch changes to a file with watch-path', {
|
||||
skip: !supportsRecursive,
|
||||
}, async () => {
|
||||
const dir = path.join(tmpdir.path, 'subdir1');
|
||||
const dir = tmpdir.resolve('subdir1');
|
||||
mkdirSync(dir);
|
||||
const file = createTmpFile();
|
||||
const watchedFile = createTmpFile('', '.js', dir);
|
||||
|
@ -138,7 +138,7 @@ describe('watch mode', { concurrency: true, timeout: 60_000 }, () => {
|
|||
it('should watch when running an non-existing file - when specified under --watch-path', {
|
||||
skip: !supportsRecursive
|
||||
}, async () => {
|
||||
const dir = path.join(tmpdir.path, 'subdir2');
|
||||
const dir = tmpdir.resolve('subdir2');
|
||||
mkdirSync(dir);
|
||||
const file = path.join(dir, 'non-existing.js');
|
||||
const watchedFile = createTmpFile('', '.js', dir);
|
||||
|
@ -156,7 +156,7 @@ describe('watch mode', { concurrency: true, timeout: 60_000 }, () => {
|
|||
it('should watch when running an non-existing file - when specified under --watch-path with equals', {
|
||||
skip: !supportsRecursive
|
||||
}, async () => {
|
||||
const dir = path.join(tmpdir.path, 'subdir3');
|
||||
const dir = tmpdir.resolve('subdir3');
|
||||
mkdirSync(dir);
|
||||
const file = path.join(dir, 'non-existing.js');
|
||||
const watchedFile = createTmpFile('', '.js', dir);
|
||||
|
@ -295,21 +295,21 @@ console.log(values.random);
|
|||
it('should not watch when running an missing file', {
|
||||
skip: !supportsRecursive
|
||||
}, async () => {
|
||||
const nonExistingfile = path.join(tmpdir.path, `${tmpFiles++}.js`);
|
||||
const nonExistingfile = tmpdir.resolve(`${tmpFiles++}.js`);
|
||||
await failWriteSucceed({ file: nonExistingfile, watchedFile: nonExistingfile });
|
||||
});
|
||||
|
||||
it('should not watch when running an missing mjs file', {
|
||||
skip: !supportsRecursive
|
||||
}, async () => {
|
||||
const nonExistingfile = path.join(tmpdir.path, `${tmpFiles++}.mjs`);
|
||||
const nonExistingfile = tmpdir.resolve(`${tmpFiles++}.mjs`);
|
||||
await failWriteSucceed({ file: nonExistingfile, watchedFile: nonExistingfile });
|
||||
});
|
||||
|
||||
it('should watch changes to previously missing dependency', {
|
||||
skip: !supportsRecursive
|
||||
}, async () => {
|
||||
const dependency = path.join(tmpdir.path, `${tmpFiles++}.js`);
|
||||
const dependency = tmpdir.resolve(`${tmpFiles++}.js`);
|
||||
const relativeDependencyPath = `./${path.basename(dependency)}`;
|
||||
const dependant = createTmpFile(`console.log(require('${relativeDependencyPath}'))`);
|
||||
|
||||
|
@ -320,7 +320,7 @@ console.log(values.random);
|
|||
skip: !supportsRecursive
|
||||
}, async () => {
|
||||
const relativeDependencyPath = `./${tmpFiles++}.mjs`;
|
||||
const dependency = path.join(tmpdir.path, relativeDependencyPath);
|
||||
const dependency = tmpdir.resolve(relativeDependencyPath);
|
||||
const dependant = createTmpFile(`import ${JSON.stringify(relativeDependencyPath)}`, '.mjs');
|
||||
|
||||
await failWriteSucceed({ file: dependant, watchedFile: dependency });
|
||||
|
|
|
@ -4,7 +4,6 @@ const tmpdir = require('../common/tmpdir');
|
|||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
const util = require('util');
|
||||
const { join } = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
// Test that --prof also tracks Worker threads.
|
||||
|
@ -67,7 +66,7 @@ if (process.argv[2] === 'child') {
|
|||
|
||||
for (const logfile of logfiles) {
|
||||
const lines = fs.readFileSync(
|
||||
join(tmpdir.path, logfile), 'utf8').split('\n');
|
||||
tmpdir.resolve(logfile), 'utf8').split('\n');
|
||||
const ticks = lines.filter((line) => /^tick,/.test(line)).length;
|
||||
|
||||
// Test that at least 15 ticks have been recorded for both parent and child
|
||||
|
|
|
@ -15,10 +15,9 @@ if (isCPPSymbolsNotMapped) {
|
|||
|
||||
const assert = require('assert');
|
||||
const { spawn, spawnSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const { writeFileSync } = require('fs');
|
||||
|
||||
const LOG_FILE = path.join(tmpdir.path, 'tick-processor.log');
|
||||
const LOG_FILE = tmpdir.resolve('tick-processor.log');
|
||||
const RETRY_TIMEOUT = 150;
|
||||
const BROKEN_PART = 'tick,';
|
||||
const WARN_REG_EXP = /\(node:\d+\) \[BROKEN_PROFILE_FILE] Warning: Profile file .* is broken/;
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
require('../common');
|
||||
const fs = require('fs');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const LOG_FILE = path.join(tmpdir.path, 'tick-processor.log');
|
||||
const LOG_FILE = tmpdir.resolve('tick-processor.log');
|
||||
const RETRY_TIMEOUT = 150;
|
||||
|
||||
function runTest(test) {
|
||||
|
|
|
@ -7,9 +7,9 @@ const { join } = require('path');
|
|||
const { WASI } = require('wasi');
|
||||
const modulePath = join(__dirname, 'wasm', 'stdin.wasm');
|
||||
const buffer = readFileSync(modulePath);
|
||||
const stdinFile = join(tmpdir.path, 'stdin.txt');
|
||||
const stdoutFile = join(tmpdir.path, 'stdout.txt');
|
||||
const stderrFile = join(tmpdir.path, 'stderr.txt');
|
||||
const stdinFile = tmpdir.resolve('stdin.txt');
|
||||
const stdoutFile = tmpdir.resolve('stdout.txt');
|
||||
const stderrFile = tmpdir.resolve('stderr.txt');
|
||||
|
||||
tmpdir.refresh();
|
||||
// Write 33 x's. The test's buffer only holds 31 x's + a terminator.
|
||||
|
|
|
@ -38,15 +38,15 @@ if (process.argv[2] === 'wasi-child') {
|
|||
|
||||
// Setup the sandbox environment.
|
||||
tmpdir.refresh();
|
||||
const sandbox = path.join(tmpdir.path, 'sandbox');
|
||||
const sandbox = tmpdir.resolve('sandbox');
|
||||
const sandboxedFile = path.join(sandbox, 'input.txt');
|
||||
const externalFile = path.join(tmpdir.path, 'outside.txt');
|
||||
const externalFile = tmpdir.resolve('outside.txt');
|
||||
const sandboxedDir = path.join(sandbox, 'subdir');
|
||||
const sandboxedSymlink = path.join(sandboxedDir, 'input_link.txt');
|
||||
const escapingSymlink = path.join(sandboxedDir, 'outside.txt');
|
||||
const loopSymlink1 = path.join(sandboxedDir, 'loop1');
|
||||
const loopSymlink2 = path.join(sandboxedDir, 'loop2');
|
||||
const sandboxedTmp = path.join(tmpdir.path, 'tmp');
|
||||
const sandboxedTmp = tmpdir.resolve('tmp');
|
||||
|
||||
fs.mkdirSync(sandbox);
|
||||
fs.mkdirSync(sandboxedDir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue