Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test,benchmark: use tmpdir.fileURL() #49138

Merged
Merged
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
4 changes: 1 addition & 3 deletions benchmark/esm/esm-loader-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// general startup, does not test lazy operations
'use strict';
const fs = require('node:fs');
const path = require('node:path');
const common = require('../common.js');

const tmpdir = require('../../test/common/tmpdir.js');
const { pathToFileURL } = require('node:url');

const benchmarkDirectory = pathToFileURL(path.resolve(tmpdir.path, 'benchmark-import'));
const benchmarkDirectory = tmpdir.fileURL('benchmark-import');

const configs = {
n: [1e3],
Expand Down
5 changes: 1 addition & 4 deletions test/es-module/test-esm-dynamic-import-mutating-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ const tmpdir = require('../common/tmpdir');

const assert = require('node:assert');
const fs = require('node:fs/promises');
const { pathToFileURL } = require('node:url');

tmpdir.refresh();
const tmpDir = pathToFileURL(tmpdir.path);

const target = new URL(`./${Math.random()}.mjs`, tmpDir);
const target = tmpdir.fileURL(`${Math.random()}.mjs`);

(async () => {

Expand Down
5 changes: 1 addition & 4 deletions test/es-module/test-esm-dynamic-import-mutating-fs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import tmpdir from '../common/tmpdir.js';
import assert from 'node:assert';
import fs from 'node:fs/promises';
import { execPath } from 'node:process';
import { pathToFileURL } from 'node:url';

tmpdir.refresh();
const tmpDir = pathToFileURL(tmpdir.path);

const target = new URL(`./${Math.random()}.mjs`, tmpDir);
const target = tmpdir.fileURL(`${Math.random()}.mjs`);

await assert.rejects(import(target), { code: 'ERR_MODULE_NOT_FOUND' });

Expand Down
5 changes: 0 additions & 5 deletions test/node-api/test_policy/test_policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ const policyFilepath = path.join(tmpdir.path, 'policy');
const depFilepath = require.resolve(`./build/${common.buildType}/binding.node`);
const depURL = pathToFileURL(depFilepath);

const tmpdirURL = pathToFileURL(tmpdir.path);
if (!tmpdirURL.pathname.endsWith('/')) {
tmpdirURL.pathname += '/';
}

const depBody = fs.readFileSync(depURL);
function writePolicy(...resources) {
const manifest = { resources: {} };
Expand Down
Loading