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

Fix absolute patterns with glob #10121

Merged
merged 12 commits into from
Apr 23, 2024
Merged

Fix absolute patterns with glob #10121

merged 12 commits into from
Apr 23, 2024

Conversation

zackradisic
Copy link
Contributor

@zackradisic zackradisic commented Apr 9, 2024

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)

Copy link

github-actions bot commented Apr 9, 2024

Copy link

github-actions bot commented Apr 9, 2024

Copy link

github-actions bot commented Apr 9, 2024

@@ -445,6 +446,15 @@ test("glob.scan('.')", async () => {
expect(entries).toContain("README.md");
});

test("absolute path pattern should ignore cwd and start at the proper path", async () => {
Copy link
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
Collaborator

tests timed out on Windows
image

@Jarred-Sumner
Copy link
Collaborator

conflict

@Jarred-Sumner
Copy link
Collaborator

glob scan test is failing

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
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 \

Copy link

github-actions bot commented Apr 22, 2024

@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
Collaborator

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

// `/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
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
Collaborator

one nitpicky comment but lets merge

return Maybe(void).success;
}
const errpath = try this.walker.arena.allocator().dupeZ(u8, path);
return .{ .err = e.withPath(errpath) };
Copy link
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

@Jarred-Sumner Jarred-Sumner merged commit 528a84d into main Apr 23, 2024
44 of 52 checks passed
@Jarred-Sumner Jarred-Sumner deleted the zack/fix-glob branch April 23, 2024 23:00
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