Skip to content

Fix absolute patterns with glob - #10121

Merged
Jarred-Sumner merged 12 commits into
mainfrom
zack/fix-glob
Apr 23, 2024
Merged

Jarred-Sumner merged 12 commits into
mainfrom
zack/fix-glob

Conversation

@zackradisic

@zackradisic zackradisic commented Apr 9, 2024 •

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Code changes

This fixes a bug where absolute patterns with Bun.Glob were not working

Fixes #8304

How did you verify your code works?

  • I included a test for the new code, or existing tests cover it

  • I ran my tests locally and they pass (bun-debug test test-file-name.test)

  • I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be

  • I included a test for the new code, or an existing test covers it

  • JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed

  • I wrote TypeScript/JavaScript tests and they pass locally (bun-debug test test-file-name.test)

@github-actions

github-actions Bot commented Apr 9, 2024 •

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Apr 9, 2024 •

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Apr 9, 2024 •

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Apr 9, 2024 •

Copy link
Copy Markdown
Contributor

Comment thread test/js/bun/glob/scan.test.ts Outdated
expect(entries).toContain("README.md");
});

test("absolute path pattern should ignore cwd and start at the proper path", async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we get more tests for this? is there a way to run all the tests that run against relative paths to also run against absolute paths?

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

tests timed out on Windows
image

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

conflict

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

glob scan test is failing

Comment thread src/glob.zig
if (pattern[component.start + component.len -| 1] == '/') {
component.trailing_sep = true;
} else if (comptime bun.Environment.isWindows) {
component.trailing_sep = pattern[component.start + component.len -| 1] == '\\';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should probably be any separator instead of specifically \

@github-actions

github-actions Bot commented Apr 22, 2024 •

Copy link
Copy Markdown
Contributor

❌ @zackradisic, your commit has failing tests :(

💪 2 failing tests Darwin AARCH64

💻 1 failing tests Darwin x64 baseline

💻 2 failing tests Darwin x64

🐧💪 4 failing tests Linux AARCH64

🐧🖥 2 failing tests Linux x64 baseline

🐧🖥 2 failing tests Linux x64

🪟💻 13 failing tests Windows x64 baseline

🪟💻 14 failing tests Windows x64

View logs

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

@zackradisic the next step for this PR is to fix the failing scan test

Comment thread src/glob.zig
// `/Users/zackradisic/foo/bar`
// In that case we don't need to do any walking and can just open up the FS entry
if (component_idx >= this.walker.patternComponents.items.len) {
const path = try this.walker.arena.allocator().dupeZ(u8, path_without_special_syntax);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

does this need to be duplicated twice

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

one nitpicky comment but lets merge

Comment thread src/glob.zig
return Maybe(void).success;
}
const errpath = try this.walker.arena.allocator().dupeZ(u8, path);
return .{ .err = e.withPath(errpath) };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I suspect there will be more errors to ignore here. Like EPERM, EACCESS, EBUSY etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Globbing /tmp/xx/*.txt incorrectly returns empty list

2 participants