zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2ca7cc46c41dc5fe91fe385df4f3330634bd88f3 (tree)
parent aaf46187ab7bf23c87a275e2755a9bd01f3c93cf
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon,  9 Oct 2023 20:48:39 -0700

Package.Fetch: fix inclusions not working for directories

Oops, the loop was checking the wrong variable! Added a unit test.

Diffstat:
Msrc/Package/Fetch.zig | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig @@ -1510,12 +1510,22 @@ const Filter = struct { // Check if any included paths are parent directories of sub_path. var dirname = sub_path; while (std.fs.path.dirname(dirname)) |next_dirname| { - if (self.include_paths.contains(sub_path)) return true; + if (self.include_paths.contains(next_dirname)) return true; dirname = next_dirname; } return false; } + + test includePath { + const gpa = std.testing.allocator; + var filter: Filter = .{}; + defer filter.include_paths.deinit(gpa); + + try filter.include_paths.put(gpa, "src", {}); + try std.testing.expect(filter.includePath("src/core/unix/SDL_poll.c")); + try std.testing.expect(!filter.includePath(".gitignore")); + } }; pub fn depDigest( @@ -1556,3 +1566,7 @@ const git = @import("Fetch/git.zig"); const Package = @import("../Package.zig"); const Manifest = Package.Manifest; const ErrorBundle = std.zig.ErrorBundle; + +test { + _ = Filter; +}