Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/common/v8-max-heap-size-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const assert = require('assert');
const { spawnSync } = require('child_process');
const path = require('path');
const fs = require('fs');
const tmpdir = require('./tmpdir');

Expand All @@ -14,7 +13,7 @@ const testScript = `
`;

tmpdir.refresh();
const scriptPath = path.join(tmpdir.path, 'heap-limit-test.js');
const scriptPath = tmpdir.resolve('heap-limit-test.js');
fs.writeFileSync(scriptPath, testScript);

const child = spawnSync(
Expand Down
5 changes: 2 additions & 3 deletions test/known_issues/test-fs-cp-async-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

const common = require('../common');
const { mkdirSync, promises } = require('fs');
const { join } = require('path');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();

const tmpA = join(tmpdir.path, 'a');
const tmpB = join(tmpdir.path, 'b');
const tmpA = tmpdir.resolve('a');
const tmpB = tmpdir.resolve('b');

mkdirSync(tmpA, { recursive: true });

Expand Down
4 changes: 2 additions & 2 deletions test/known_issues/test-fs-cp-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const {
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const pathA = join(tmpdir.path, 'a');
const pathA = tmpdir.resolve('a');
const pathAC = join(pathA, 'c');
const pathB = join(tmpdir.path, 'b');
const pathB = tmpdir.resolve('b');
mkdirSync(pathAC, { recursive: true });

cpSync(Buffer.from(pathA), Buffer.from(pathB), {
Expand Down
9 changes: 4 additions & 5 deletions test/known_issues/test-fs-cp-non-utf8.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ if (!common.isLinux) {
}

const assert = require('assert');
const { join } = require('path');
const path = require('path');
const { sep } = require('path');
const tmpdir = require('../common/tmpdir');
const {
cpSync,
Expand All @@ -22,8 +21,8 @@ const {
} = require('fs');
tmpdir.refresh();

const tmpdirPath = Buffer.from(join(tmpdir.path, 'a', 'c'));
const sepBuf = Buffer.from(path.sep);
const tmpdirPath = Buffer.from(tmpdir.resolve('a', 'c'));
const sepBuf = Buffer.from(sep);

mkdirSync(tmpdirPath, { recursive: true });

Expand All @@ -48,7 +47,7 @@ assert.strictEqual(readFileSync(testPath, 'utf8'), 'test content');
// The cpSync is expected to fail because the implementation does not
// properly handle non-UTF8 names in the path.

cpSync(join(tmpdir.path, 'a'), join(tmpdir.path, 'b'), {
cpSync(tmpdir.resolve('a'), tmpdir.resolve('b'), {
recursive: true,
filter: common.mustCall(() => true, 1),
});
4 changes: 2 additions & 2 deletions test/parallel/test-common-wpt-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function main() {
const atob = discover('atob');
assert.strictEqual(atob.serial, false);
assert.deepStrictEqual(atob.tests.map((test) => test.id), ['base64.any.html', 'base64.any.worker.html']);
const reportRoot = path.join(tmpdir.path, 'reports');
const reportRoot = tmpdir.resolve('reports');
const canReport = ['darwin', 'linux', 'win32'].includes(process.platform);
if (canReport) fs.mkdirSync(reportRoot, { recursive: true });
for (const [index, group] of atob.tests.entries()) {
Expand Down Expand Up @@ -104,7 +104,7 @@ function main() {
assert.doesNotMatch(skippedOutput, /\[PASS\]/);

if (common.hasSQLite) {
const root = path.join(tmpdir.path, 'discovery');
const root = tmpdir.resolve('discovery');
const directory = path.join(root, '.tmp.probe');
fs.mkdirSync(directory, { recursive: true });
const sentinel = path.join(directory, 'sentinel');
Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const tmpdir = require('../common/tmpdir');
const assert = require('node:assert');
const { test, it, describe } = require('node:test');
const { chmodSync, writeFileSync, constants } = require('node:fs');
const { join } = require('node:path');

const onlyIfNodeOptionsSupport = { skip: process.config.variables.node_without_node_options };
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
Expand Down Expand Up @@ -60,7 +59,7 @@ describe('runtime version checks', () => {

async function runConfig(config, filename = 'version-config.json') {
tmpdir.refresh();
const configPath = join(tmpdir.path, filename);
const configPath = tmpdir.resolve(filename);
writeFileSync(configPath, JSON.stringify(config));

return spawnPromisified(process.execPath, [
Expand Down Expand Up @@ -775,7 +774,7 @@ test('should throw an error when the file is non readable', {
skip: isWindows || process.getuid() === 0,
}, async () => {
tmpdir.refresh();
const dest = join(tmpdir.path, 'node.config.json');
const dest = tmpdir.resolve('node.config.json');
writeFileSync(dest, JSON.stringify({
nodeOptions: { 'max-http-header-size': 10 }
}));
Expand Down
25 changes: 12 additions & 13 deletions test/parallel/test-crypto-key-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if (isBoringSSL)

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { pathToFileURL } = require('url');
const {
createPublicKey,
Expand All @@ -36,7 +35,7 @@ const data = Buffer.from('hello store');

{
const { privateKey, publicKey } = generateKeyPairSync('ed25519');
const file = path.join(tmpdir.path, 'priv.pem');
const file = tmpdir.resolve('priv.pem');
fs.writeFileSync(file, privateKey.export({ format: 'pem', type: 'pkcs8' }));
const url = pathToFileURL(file);

Expand Down Expand Up @@ -66,7 +65,7 @@ const data = Buffer.from('hello store');
const { privateKey, publicKey } = generateKeyPairSync('rsa', {
modulusLength: 2048,
});
const file = path.join(tmpdir.path, 'rsa.pem');
const file = tmpdir.resolve('rsa.pem');
fs.writeFileSync(file, privateKey.export({ format: 'pem', type: 'pkcs8' }));
const url = pathToFileURL(file);
const plaintext = Buffer.from('hello rsa store');
Expand All @@ -91,7 +90,7 @@ const data = Buffer.from('hello store');
} else {
const alice = generateKeyPairSync('x25519');
const bob = generateKeyPairSync('x25519');
const file = path.join(tmpdir.path, 'x25519.pem');
const file = tmpdir.resolve('x25519.pem');
fs.writeFileSync(file, alice.privateKey.export({
format: 'pem',
type: 'pkcs8',
Expand All @@ -117,7 +116,7 @@ const data = Buffer.from('hello store');
// Encrypted PKCS#8 with passphrase via { key: url, passphrase }.
const passphrase = 'correct-passphrase';
const { privateKey, publicKey } = generateKeyPairSync('ed25519');
const file = path.join(tmpdir.path, 'enc.pem');
const file = tmpdir.resolve('enc.pem');
fs.writeFileSync(file, privateKey.export({
format: 'pem', type: 'pkcs8', cipher: 'aes-256-cbc', passphrase,
}));
Expand All @@ -139,7 +138,7 @@ const data = Buffer.from('hello store');

{
// A URL is only accepted in private-key contexts.
const url = pathToFileURL(path.join(tmpdir.path, 'priv.pem'));
const url = pathToFileURL(tmpdir.resolve('priv.pem'));
assert.throws(() => createPublicKey(url), {
code: 'ERR_INVALID_ARG_TYPE',
});
Expand Down Expand Up @@ -188,7 +187,7 @@ const data = Buffer.from('hello store');
{
// A readable URI that holds no private key is distinguishable from a URI
// that could not be opened at all.
const file = path.join(tmpdir.path, 'nope.pem');
const file = tmpdir.resolve('nope.pem');
fs.writeFileSync(file, 'not a key');
assert.throws(() => createPrivateKey(pathToFileURL(file)), {
code: 'ERR_CRYPTO_OPERATION_FAILED',
Expand All @@ -199,7 +198,7 @@ const data = Buffer.from('hello store');
// portable either: some builds leave a generic STORE `unsupported` on top of
// the error the loader itself raised. The reason is reported either way.
assert.throws(
() => createPrivateKey(pathToFileURL(path.join(tmpdir.path, 'missing.pem'))),
() => createPrivateKey(pathToFileURL(tmpdir.resolve('missing.pem'))),
(err) => {
assert.match([err.message, ...err.opensslErrorStack ?? []].join('\n'),
/No such file or directory/);
Expand All @@ -219,7 +218,7 @@ const data = Buffer.from('hello store');
// Only a genuine URL selects the STORE loader. A plain object that merely
// exposes `href` and `protocol` must not be treated as one, otherwise an
// attacker-supplied JWK could redirect the load to a URI of their choosing.
const file = path.join(tmpdir.path, 'priv.pem');
const file = tmpdir.resolve('priv.pem');
const spoofed = {
kty: 'EC',
crv: 'P-256',
Expand All @@ -244,9 +243,9 @@ const data = Buffer.from('hello store');
// Read the URI from the URL's private state. Public accessors on a branded
// subclass must not redirect a previously created URL to a different key.
const trustedHref = pathToFileURL(
path.join(tmpdir.path, 'priv.pem')).href;
tmpdir.resolve('priv.pem')).href;
const redirectHref = pathToFileURL(
path.join(tmpdir.path, 'rsa.pem')).href;
tmpdir.resolve('rsa.pem')).href;
class RedirectingURL extends URL {
get href() { return redirectHref; }
}
Expand Down Expand Up @@ -274,7 +273,7 @@ const data = Buffer.from('hello store');

// Replacing `protocol` must not turn an opaque STORE URI into a file path.
const filePathname = pathToFileURL(
path.join(tmpdir.path, 'priv.pem')).pathname;
tmpdir.resolve('priv.pem')).pathname;
const opaqueURL = new URL(`pkcs11:${filePathname}`);
const protocolDescriptor = Object.getOwnPropertyDescriptor(
URL.prototype, 'protocol');
Expand All @@ -294,7 +293,7 @@ const data = Buffer.from('hello store');
{
// The URI is handed to OpenSSL as a NUL-terminated C string, so an embedded
// NUL must be rejected rather than silently truncating the path.
const file = path.join(tmpdir.path, 'priv.pem');
const file = tmpdir.resolve('priv.pem');
assert.throws(
() => createPrivateKey(new URL(`${pathToFileURL(file).href}%00.txt`)), {
code: 'ERR_INVALID_ARG_VALUE',
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-diagnostics-channel-child-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const common = require('../common');
const assert = require('assert');
const { spawn, ChildProcess } = require('child_process');
const dc = require('diagnostics_channel');
const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');

Expand Down Expand Up @@ -67,7 +66,7 @@ const testFailingSpawnENOENT = common.mustCall(() => {

const testFailingSpawnEACCES = !common.isWindows ? common.mustCall(() => {
tmpdir.refresh();
const noExecFile = path.join(tmpdir.path, 'no-exec');
const noExecFile = tmpdir.resolve('no-exec');
fs.writeFileSync(noExecFile, '');
fs.chmodSync(noExecFile, 0o644);

Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-chown-negative-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();

const testFile = path.join(tmpdir.path, 'chown-test-file.txt');
const testFile = tmpdir.resolve('chown-test-file.txt');

fs.writeFileSync(testFile, 'test content for chown');

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-cp-async-symlink-targets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mkdirSync(join(src, 'real'), { recursive: true });
writeFileSync(join(src, 'real', 'file'), 'data');
symlinkSync('real', join(src, 'alias'));
symlinkSync('alias/file', join(src, 'link'));
const absoluteTarget = join(tmpdir.path, 'x', '..', 'elsewhere');
const absoluteTarget = tmpdir.resolve('x', '..', 'elsewhere');
symlinkSync(absoluteTarget, join(src, 'abs'));

for (const filter of [undefined, () => true]) {
Expand Down
12 changes: 4 additions & 8 deletions test/parallel/test-fs-cp-sync-dereference.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@ const {
statSync
} = require('fs');

const {
join,
} = require('path');

const assert = require('assert');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const pathA = join(tmpdir.path, 'a'); // file
const pathB = join(tmpdir.path, 'b'); // directory
const pathC = join(tmpdir.path, 'c'); // c -> b
const pathD = join(tmpdir.path, 'd'); // d -> b
const pathA = tmpdir.resolve('a'); // file
const pathB = tmpdir.resolve('b'); // directory
const pathC = tmpdir.resolve('c'); // c -> b
const pathD = tmpdir.resolve('d'); // d -> b

writeFileSync(pathA, 'file a');
mkdirSync(pathB);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-cp-sync-unicode-dest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import tmpdir from '../common/tmpdir.js';

tmpdir.refresh();

const src = join(tmpdir.path, 'src');
const src = tmpdir.resolve('src');
mkdirSync(join(src, 'subdir'), { recursive: true });
writeFileSync(join(src, 'file1.txt'), 'Hello World');
writeFileSync(join(src, 'subdir', 'nested.txt'), 'Nested File');

const dest = join(tmpdir.path, 'Eyjafjallajökull-Pranckevičius');
const dest = tmpdir.resolve('Eyjafjallajökull-Pranckevičius');
cpSync(src, dest, { recursive: true, force: true });

const destFiles = readdirSync(dest);
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-fchown-negative-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();

const testFilePath = path.join(tmpdir.path, 'fchown-test-file.txt');
const testFilePath = tmpdir.resolve('fchown-test-file.txt');

fs.writeFileSync(testFilePath, 'test content for fchown');

Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-fs-lchown-negative-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();

const testFile = path.join(tmpdir.path, 'lchown-test-file.txt');
const testLink = path.join(tmpdir.path, 'lchown-test-link');
const testFile = tmpdir.resolve('lchown-test-file.txt');
const testLink = tmpdir.resolve('lchown-test-link');

fs.writeFileSync(testFile, 'test content for lchown');
fs.symlinkSync(testFile, testLink);
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-mkdtemp-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const prefixString = path.join(tmpdir.path, 'buffer-');
const prefixString = tmpdir.resolve('buffer-');
const prefixBuffer = Buffer.from(prefixString);

// 1. Test Sync API
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-mkdtempDisposableSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ if (isMainThread) {
const first = fs.mkdtempDisposableSync('first.');
const second = fs.mkdtempDisposableSync('second.');

const fullFirstPath = path.join(tmpdir.path, first.path);
const fullSecondPath = path.join(tmpdir.path, second.path);
const fullFirstPath = tmpdir.resolve(first.path);
const fullSecondPath = tmpdir.resolve(second.path);

assert(fs.existsSync(fullFirstPath));
assert(fs.existsSync(fullSecondPath));
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-promises-mkdtempDisposable.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async function chdirDoesNotAffectRemoval() {
const first = await fsPromises.mkdtempDisposable('first.');
const second = await fsPromises.mkdtempDisposable('second.');

const fullFirstPath = path.join(tmpdir.path, first.path);
const fullSecondPath = path.join(tmpdir.path, second.path);
const fullFirstPath = tmpdir.resolve(first.path);
const fullSecondPath = tmpdir.resolve(second.path);

assert(fs.existsSync(fullFirstPath));
assert(fs.existsSync(fullSecondPath));
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-readfile-utf8-fast-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

require('../common');
const fs = require('node:fs');
const path = require('node:path');
const assert = require('node:assert');
const { describe, it } = require('node:test');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();

function writeFile(name, buf) {
const p = path.join(tmpdir.path, name);
const p = tmpdir.resolve(name);
fs.writeFileSync(p, buf);
return p;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function countOccurrences(haystack, needle) {
return count;
}

const dirPath = path.join(tmpdir.path, '速_dir');
const dirPath = tmpdir.resolve('速_dir');
const filePath = path.join(dirPath, 'test_file.txt');

// Create a directory and a file within it
Expand Down
Loading
Loading