Skip to content

test: add missing cctest/test_path.cc - #52148

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:add-missing-cctest
Mar 21, 2024
Merged

test: add missing cctest/test_path.cc#52148
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:add-missing-cctest

Conversation

@anonrig

@anonriganonrig commented Mar 19, 2024

Copy link
Copy Markdown
Member

We weren't running and testing test_path.cc. This change ensures that make cctest runs the test file.

cc @RafaelGSS @nodejs/path

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp

@anonriganonrig added fast-track PRs that do not need to wait for 48 hours to land. request-ci Add this label to start a Jenkins CI on a PR. labels Mar 19, 2024
@nodejs-github-botnodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. labels Mar 19, 2024
@github-actions

Copy link
Copy Markdown
Contributor

Fast-track has been requested by @anonrig. Please 👍 to approve.

@anonrig
anonrig requested a review from RafaelGSSMarch 19, 2024 00:55
@anonriganonrig added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 19, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 19, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@anonrig

Copy link
Copy Markdown
MemberAuthor

It seems the existing tests are failing. cc @RafaelGSS @nodejs/platform-windows

@aduh95

Copy link
Copy Markdown
Contributor

It looks like cctest/test_path.cc doesn't pass on Windows

C:\workspace\node-compile-windows\node\test\cctest\test_path.cc:21
Expected equality of these values:
PathResolve(*env, {"c:/ignore", "d:\\a/b\\c/d", "\\e.exe"})
Which is: "\\e.exe"
"d:\\e.exe"

@StefanStojanovic

Copy link
Copy Markdown
Contributor

The reason behind this is the PathResolve implementation on Windows. All of the failing cases have one thing in common - the last path in the list starts with a path separator (either \\ or /) thus it is evaluated as an absolute path, which it is not.

I see that those test cases are taken from test-path-resolve.js and that the implementation is taken from path.js. However, I found this difference when comparing the two path resolve implementations: JS code, C++ code. Changing this solved the test failures for me locally.

diff --git a/src/path.cc b/src/path.cc
index 6a56b750d6e..78dd5804fc3 100644
--- a/src/path.cc
+++ b/src/path.cc
@@ -101,7 +101,7 @@ std::string PathResolve(Environment* env,
const size_t numArgs = paths.size();
auto cwd = env->GetCwd(env->exec_path());
- for (int i = numArgs - 1; i >= -1 && !resolvedAbsolute; i--) {
+ for (int i = numArgs - 1; i >= -1; i--) {
std::string path;
if (i >= 0) {
path = std::string(paths[I]);

@anonrig
anonrigforce-pushed the add-missing-cctest branch from 06e0270 to d7dd131CompareMarch 19, 2024 13:54
@anonrig

Copy link
Copy Markdown
MemberAuthor

Thank you @StefanStojanovic. Updated the pull-request.

@anonriganonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 19, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 19, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@anonriganonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 21, 2024
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 21, 2024
@nodejs-github-bot
nodejs-github-bot merged commit 0b67673 into nodejs:mainMar 21, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0b67673

@anonrig
anonrig deleted the add-missing-cctest branch March 21, 2024 14:37
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
PR-URL: #52148
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@marco-ippolitomarco-ippolito mentioned this pull request May 2, 2024
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
PR-URL: #52148
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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.buildIssues and PRs related to build files or the CI.fast-trackPRs that do not need to wait for 48 hours to land.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@anonrig@nodejs-github-bot@aduh95@StefanStojanovic@GeoffreyBooth@Trott@lpinca@richardlau@atlowChemi