Skip to content

Commit e391f4b

Browse files
LiviaMedeirosUlisesGascon
authored andcommitted
test: use tmpdir.resolve()
PR-URL: #49136 Reviewed-By: Luigi Pinca <[email protected]>
1 parent 1704f24 commit e391f4b

File tree

49 files changed

+97
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+97
-118
lines changed

test/addons/symlinked-module/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const tmpdir = require('../../common/tmpdir');
1616
tmpdir.refresh();
1717

1818
const addonPath = path.join(__dirname, 'build', common.buildType);
19-
const addonLink = path.join(tmpdir.path, 'addon');
19+
const addonLink = tmpdir.resolve('addon');
2020

2121
try {
2222
fs.symlinkSync(addonPath, addonLink, 'dir');

test/async-hooks/test-statwatcher.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ const assert = require('assert');
66
const initHooks = require('./init-hooks');
77
const { checkInvocations } = require('./hook-checks');
88
const fs = require('fs');
9-
const path = require('path');
109

1110
if (!common.isMainThread)
1211
common.skip('Worker bootstrapping works differently -> different async IDs');
1312

1413
tmpdir.refresh();
1514

16-
const file1 = path.join(tmpdir.path, 'file1');
17-
const file2 = path.join(tmpdir.path, 'file2');
15+
const file1 = tmpdir.resolve('file1');
16+
const file2 = tmpdir.resolve('file2');
1817

1918
const onchangex = (x) => (curr, prev) => {
2019
console.log(`Watcher: ${x}`);

test/common/snapshot.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
const tmpdir = require('../common/tmpdir');
44
const { spawnSync } = require('child_process');
5-
const path = require('path');
65
const fs = require('fs');
76
const assert = require('assert');
87

98
function buildSnapshot(entry, env) {
109
const child = spawnSync(process.execPath, [
1110
'--snapshot-blob',
12-
path.join(tmpdir.path, 'snapshot.blob'),
11+
tmpdir.resolve('snapshot.blob'),
1312
'--build-snapshot',
1413
entry,
1514
], {
@@ -29,14 +28,14 @@ function buildSnapshot(entry, env) {
2928

3029
assert.strictEqual(child.status, 0);
3130

32-
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
31+
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
3332
assert(stats.isFile());
3433

3534
return { child, stderr, stdout };
3635
}
3736

3837
function runWithSnapshot(entry, env) {
39-
const args = ['--snapshot-blob', path.join(tmpdir.path, 'snapshot.blob')];
38+
const args = ['--snapshot-blob', tmpdir.resolve('snapshot.blob')];
4039
if (entry !== undefined) {
4140
args.push(entry);
4241
}

test/doctool/test-apilinks.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fs.readdirSync(apilinks).forEach((fixture) => {
1919
const input = path.join(apilinks, fixture);
2020

2121
const expectedContent = fs.readFileSync(`${input}on`, 'utf8');
22-
const outputPath = path.join(tmpdir.path, `${fixture}on`);
22+
const outputPath = tmpdir.resolve(`${fixture}on`);
2323
execFileSync(
2424
process.execPath,
2525
[script, outputPath, input],

test/doctool/test-doctool-versions.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import tmpdir from '../common/tmpdir.js';
44
import assert from 'assert';
55
import { spawnSync } from 'child_process';
66
import fs from 'fs';
7-
import path from 'path';
87
import { fileURLToPath } from 'url';
98
import util from 'util';
109

@@ -29,7 +28,7 @@ const expected = [
2928
];
3029

3130
tmpdir.refresh();
32-
const versionsFile = path.join(tmpdir.path, 'versions.json');
31+
const versionsFile = tmpdir.resolve('versions.json');
3332
debuglog(`${process.execPath} ${versionsTool} ${versionsFile}`);
3433
const opts = { cwd: tmpdir.path, encoding: 'utf8' };
3534
const cp = spawnSync(process.execPath, [ versionsTool, versionsFile ], opts);

test/embedding/test-embedding.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function getReadFileCodeForPath(path) {
6363
for (const extraSnapshotArgs of [[], ['--embedder-snapshot-as-file']]) {
6464
// readSync + eval since snapshots don't support userland require() (yet)
6565
const snapshotFixture = fixtures.path('snapshot', 'echo-args.js');
66-
const blobPath = path.join(tmpdir.path, 'embedder-snapshot.blob');
66+
const blobPath = tmpdir.resolve('embedder-snapshot.blob');
6767
const buildSnapshotArgs = [
6868
`eval(${getReadFileCodeForPath(snapshotFixture)})`, 'arg1', 'arg2',
6969
'--embedder-snapshot-blob', blobPath, '--embedder-snapshot-create',
@@ -94,7 +94,7 @@ for (const extraSnapshotArgs of [[], ['--embedder-snapshot-as-file']]) {
9494
// Create workers and vm contexts after deserialization
9595
{
9696
const snapshotFixture = fixtures.path('snapshot', 'create-worker-and-vm.js');
97-
const blobPath = path.join(tmpdir.path, 'embedder-snapshot.blob');
97+
const blobPath = tmpdir.resolve('embedder-snapshot.blob');
9898
const buildSnapshotArgs = [
9999
`eval(${getReadFileCodeForPath(snapshotFixture)})`,
100100
'--embedder-snapshot-blob', blobPath, '--embedder-snapshot-create',

test/es-module/test-esm-extension-lookup-deprecation.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('ESM in main field', { concurrency: true }, () => {
1111
before(() => tmpdir.refresh());
1212

1313
it('should handle fully-specified relative path without any warning', async () => {
14-
const cwd = path.join(tmpdir.path, Math.random().toString());
14+
const cwd = tmpdir.resolve(Math.random().toString());
1515
const pkgPath = path.join(cwd, './node_modules/pkg/');
1616
await mkdir(pkgPath, { recursive: true });
1717
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
@@ -29,7 +29,7 @@ describe('ESM in main field', { concurrency: true }, () => {
2929
assert.strictEqual(code, 0);
3030
});
3131
it('should handle fully-specified absolute path without any warning', async () => {
32-
const cwd = path.join(tmpdir.path, Math.random().toString());
32+
const cwd = tmpdir.resolve(Math.random().toString());
3333
const pkgPath = path.join(cwd, './node_modules/pkg/');
3434
await mkdir(pkgPath, { recursive: true });
3535
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
@@ -48,7 +48,7 @@ describe('ESM in main field', { concurrency: true }, () => {
4848
});
4949

5050
it('should emit warning when "main" and "exports" are missing', async () => {
51-
const cwd = path.join(tmpdir.path, Math.random().toString());
51+
const cwd = tmpdir.resolve(Math.random().toString());
5252
const pkgPath = path.join(cwd, './node_modules/pkg/');
5353
await mkdir(pkgPath, { recursive: true });
5454
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
@@ -65,7 +65,7 @@ describe('ESM in main field', { concurrency: true }, () => {
6565
assert.strictEqual(code, 0);
6666
});
6767
it('should emit warning when "main" is falsy', async () => {
68-
const cwd = path.join(tmpdir.path, Math.random().toString());
68+
const cwd = tmpdir.resolve(Math.random().toString());
6969
const pkgPath = path.join(cwd, './node_modules/pkg/');
7070
await mkdir(pkgPath, { recursive: true });
7171
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
@@ -83,7 +83,7 @@ describe('ESM in main field', { concurrency: true }, () => {
8383
assert.strictEqual(code, 0);
8484
});
8585
it('should emit warning when "main" is a relative path without extension', async () => {
86-
const cwd = path.join(tmpdir.path, Math.random().toString());
86+
const cwd = tmpdir.resolve(Math.random().toString());
8787
const pkgPath = path.join(cwd, './node_modules/pkg/');
8888
await mkdir(pkgPath, { recursive: true });
8989
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');
@@ -101,7 +101,7 @@ describe('ESM in main field', { concurrency: true }, () => {
101101
assert.strictEqual(code, 0);
102102
});
103103
it('should emit warning when "main" is an absolute path without extension', async () => {
104-
const cwd = path.join(tmpdir.path, Math.random().toString());
104+
const cwd = tmpdir.resolve(Math.random().toString());
105105
const pkgPath = path.join(cwd, './node_modules/pkg/');
106106
await mkdir(pkgPath, { recursive: true });
107107
await writeFile(path.join(pkgPath, './index.js'), 'console.log("Hello World!")');

test/es-module/test-esm-resolve-type.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const {
2626
defaultResolve: resolve
2727
} = internalResolve;
2828

29-
const rel = (file) => path.join(tmpdir.path, file);
29+
const rel = (file) => tmpdir.resolve(file);
3030
const previousCwd = process.cwd();
3131
const nmDir = rel('node_modules');
3232

test/es-module/test-esm-symlink-main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const fs = require('fs');
99
tmpdir.refresh();
1010

1111
const realPath = path.resolve(__dirname, '../fixtures/es-modules/symlink.mjs');
12-
const symlinkPath = path.resolve(tmpdir.path, 'symlink.mjs');
12+
const symlinkPath = tmpdir.resolve('symlink.mjs');
1313

1414
try {
1515
fs.symlinkSync(realPath, symlinkPath);

test/es-module/test-esm-windows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const imp = (file) => {
1515

1616
(async () => {
1717
tmpdir.refresh();
18-
const rel = (file) => path.join(tmpdir.path, file);
18+
const rel = (file) => tmpdir.resolve(file);
1919

2020
{ // Load a single script
2121
const file = rel('con.mjs');

0 commit comments

Comments
 (0)