Skip to content

fs: apply exclude function to root path#57420

Merged
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
Trott:globbing-fix
Mar 16, 2025
Merged

fs: apply exclude function to root path#57420
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
Trott:globbing-fix

Conversation

@Trott
Copy link
Copy Markdown
Member

@Trott Trott commented Mar 12, 2025

In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2, rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Mar 12, 2025
@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 12, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 12, 2025
@nodejs-github-bot

This comment was marked as outdated.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.21%. Comparing base (3329efe) to head (53d6b31).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/fs/glob.js 88.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #57420   +/-   ##
=======================================
  Coverage   90.20%   90.21%           
=======================================
  Files         629      629           
  Lines      184948   184973   +25     
  Branches    36204    36220   +16     
=======================================
+ Hits       166837   166876   +39     
+ Misses      11057    11042   -15     
- Partials     7054     7055    +1     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 92.00% <88.00%> (-0.15%) ⬇️

... and 56 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Armanidashh

This comment was marked as off-topic.

@Trott
Copy link
Copy Markdown
Member Author

Trott commented Mar 12, 2025

All tests pass. This could use some reviews. @nodejs/fs

Copy link
Copy Markdown
Member

@LiviaMedeiros LiviaMedeiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM in context of exclude function per se, but I'm not sure if it fixes the issue if we consider arrays of strings.

Comment thread test/parallel/test-fs-glob.mjs
Trott added 2 commits March 13, 2025 08:54
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: nodejs#56260
@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 13, 2025
@github-actions github-actions Bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Mar 13, 2025
@github-actions

This comment was marked as outdated.

@Trott Trott removed the request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. label Mar 13, 2025
@Trott
Copy link
Copy Markdown
Member Author

Trott commented Mar 14, 2025

If someone could review (or re-review), it would let me start Jenkins CI on this.....

@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 14, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 14, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member

@LiviaMedeiros LiviaMedeiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with or without the nit.

Comment thread lib/internal/fs/glob.js Outdated
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@Trott Trott added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 16, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 16, 2025
@nodejs-github-bot nodejs-github-bot merged commit 8a5a849 into nodejs:main Mar 16, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Landed in 8a5a849

@Trott Trott deleted the globbing-fix branch March 17, 2025 21:50
aduh95 pushed a commit that referenced this pull request Mar 18, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MoLow
Copy link
Copy Markdown
Member

MoLow commented Mar 23, 2025

I am not sure if there is a benchmark for glob, but I am curios what the performance impact is here

@Trott
Copy link
Copy Markdown
Member Author

Trott commented Mar 24, 2025

I am not sure if there is a benchmark for glob, but I am curios what the performance impact is here

There is a bench-glob.js in our benchmarks, if you want to try locally and/or with the Jenkins benchmark job.

@Trott
Copy link
Copy Markdown
Member Author

Trott commented Mar 24, 2025

I am not sure if there is a benchmark for glob, but I am curios what the performance impact is here

There is a bench-glob.js in our benchmarks, if you want to try locally and/or with the Jenkins benchmark job.

I ran it locally and found a small negative performance effect. I think it's worth it to fix a bug and make the globbing correct, especially on an Experimental feature. But reasonable people might disagree. Here are my results.

                                                                                    confidence improvement accuracy (*)   (**)   (***)
fs/bench-glob.js recursive='false' mode='async' pattern='*.js' dir='lib' n=1000                    -3.77 %       ±3.77% ±5.03%  ±6.56%
fs/bench-glob.js recursive='false' mode='async' pattern='**/*' dir='lib' n=1000                     0.76 %       ±3.36% ±4.48%  ±5.84%
fs/bench-glob.js recursive='false' mode='async' pattern='**/**.js' dir='lib' n=1000                -1.36 %       ±3.50% ±4.65%  ±6.06%
fs/bench-glob.js recursive='false' mode='sync' pattern='*.js' dir='lib' n=1000                     -0.15 %       ±0.95% ±1.27%  ±1.65%
fs/bench-glob.js recursive='false' mode='sync' pattern='**/*' dir='lib' n=1000             ***     -1.83 %       ±0.48% ±0.64%  ±0.83%
fs/bench-glob.js recursive='false' mode='sync' pattern='**/**.js' dir='lib' n=1000         ***     -1.91 %       ±0.52% ±0.69%  ±0.90%
fs/bench-glob.js recursive='true' mode='async' pattern='*.js' dir='lib' n=1000                      0.40 %       ±4.89% ±6.52%  ±8.50%
fs/bench-glob.js recursive='true' mode='async' pattern='**/*' dir='lib' n=1000                      0.78 %       ±3.29% ±4.38%  ±5.70%
fs/bench-glob.js recursive='true' mode='async' pattern='**/**.js' dir='lib' n=1000                  0.02 %       ±6.81% ±9.06% ±11.79%
fs/bench-glob.js recursive='true' mode='sync' pattern='*.js' dir='lib' n=1000                       0.11 %       ±0.80% ±1.06%  ±1.38%
fs/bench-glob.js recursive='true' mode='sync' pattern='**/*' dir='lib' n=1000              ***     -1.56 %       ±0.65% ±0.86%  ±1.12%
fs/bench-glob.js recursive='true' mode='sync' pattern='**/**.js' dir='lib' n=1000          ***     -1.74 %       ±0.48% ±0.64%  ±0.84%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 12 comparisons, you can thus expect the following amount of false-positive results:
  0.60 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.12 false positives, when considering a   1% risk acceptance (**, ***),
  0.01 false positives, when considering a 0.1% risk acceptance (***)

RafaelGSS pushed a commit that referenced this pull request Apr 1, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 1, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Apr 8, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: nodejs#56260
PR-URL: nodejs#57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 14, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 14, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 14, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 14, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 15, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 16, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 17, 2025
In at least some situations, the root path was
being added to the results of globbing even if
it matched the optional exclude function.

In the relevant test file, a variable was renamed
for consistency. (There was a patterns and pattern2,
rather than patterns2.) The test case is added to
patterns2.

Fixes: #56260
PR-URL: #57420
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Apr 20, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [node](https://nodejs.org) ([source](https://github.com/nodejs/node)) | minor | `23.10.0` -> `23.11.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>nodejs/node (node)</summary>

### [`v23.11.0`](https://github.com/nodejs/node/releases/tag/v23.11.0): 2025-04-01, Version 23.11.0 (Current), @&#8203;aduh95

[Compare Source](nodejs/node@v23.10.0...v23.11.0)

##### Notable Changes

-   \[[`64b086740a`](nodejs/node@64b086740a)] - **(SEMVER-MINOR)** **assert**: implement partial error comparison (Ruben Bridgewater) [#&#8203;57370](nodejs/node#57370)
-   \[[`053cef70e0`](nodejs/node@053cef70e0)] - **(SEMVER-MINOR)** **crypto**: add optional callback to `crypto.diffieHellman` (Filip Skokan) [#&#8203;57274](nodejs/node#57274)
-   \[[`f8aff90235`](nodejs/node@f8aff90235)] - **(SEMVER-MINOR)** **process**: add `execve` (Paolo Insogna) [#&#8203;56496](nodejs/node#56496)
-   \[[`4b04c92d7d`](nodejs/node@4b04c92d7d)] - **(SEMVER-MINOR)** **sqlite**: add `StatementSync.prototype.columns()` (Colin Ihrig) [#&#8203;57490](