Skip to content

Conversation

@LiviaMedeiros
Copy link
Member

@LiviaMedeirosLiviaMedeiros commented Aug 6, 2023

Almost every time tmpdir.path is used in tests, we have to import path to use it.
Whenever we need URL of something in tmpdir, we also have to import url.pathToFileURL.
Adding tmpdir.url would reduce

import{join}from'node:path';import{pathToFileURL}from'node:url';consttestFile=pathToFileURL(join(tmpdir.path,'subdir','tst-file-123'));

to

consttestFile=tmpdir.resolve('subdir','tst-file-123');

or to native resolving

consttmpBase=tmpdir.fileURL();consttestFile=newURL('subdir/tst-file-123',tmpBase);

Additionally, maybe we could add path-oriented tmpdir.resolve(...paths) to replace path.join(tmpdir.path, ...paths) in tests?

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Aug 6, 2023
@tniessen
Copy link
Member

Why is the URL not a URL?

@LiviaMedeiros
Copy link
MemberAuthor

Why is the URL not a URL?

For consistency with import.meta.url and general guideline. No strong opinion here.

@tniessen
Copy link
Member

I see. For anyone else wondering the same thing, it sounds like the main issue is that URL is meant to be mutable, which is undesirable for values that are not meant to be modified.

@aduh95
Copy link
Contributor

We could have tmpdir.fileURL() which would return a new URL instance, and would accept a relative URL as optional parameter, that would be consistent with fixtures.mjs. wdyt?

@joyeecheung
Copy link
Member

Considering we also already have fixtures.fileURL() and fixtures.path() I think tmpdir.fileURL() and tmpdir.resolve() (because tmpdir.path is already taken) would make a lot of sense (I've always wondered why we don't have tmpdir.resolve() whenever I have to do path.join(tmpdir.path))

@LiviaMedeirosLiviaMedeiros changed the title test: add tmpdir.urltest: add tmpdir.fileURL()Aug 9, 2023
@LiviaMedeirosLiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 9, 2023
@aduh95aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 9, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@aduh95aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 10, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 10, 2023
@nodejs-github-botnodejs-github-bot merged commit 7bbcb29 into nodejs:mainAug 10, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 7bbcb29

martenrichter pushed a commit to martenrichter/node that referenced this pull request Aug 13, 2023
PR-URL: nodejs#49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 15, 2023
PR-URL: #49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
@UlisesGasconUlisesGascon mentioned this pull request Aug 15, 2023
RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Aug 15, 2023
PR-URL: nodejs#49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
rluvaton pushed a commit to rluvaton/node that referenced this pull request Aug 15, 2023
PR-URL: nodejs#49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 17, 2023
PR-URL: #49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 21, 2023
UlisesGascon pushed a commit that referenced this pull request Sep 10, 2023
targos pushed a commit to targos/node that referenced this pull request Nov 11, 2023
PR-URL: nodejs#49040 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
targos pushed a commit that referenced this pull request Nov 23, 2023
PR-URL: #49040 Backport-PR-URL: #50669 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
targos pushed a commit that referenced this pull request Nov 27, 2023
@targostargos mentioned this pull request Nov 28, 2023
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
PR-URL: nodejs/node#49040 Backport-PR-URL: nodejs/node#50669 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
PR-URL: nodejs/node#49040 Backport-PR-URL: nodejs/node#50669 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@LiviaMedeiros@tniessen@aduh95@joyeecheung@nodejs-github-bot@targos