mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 08:33:15 +00:00
Package.Fetch: fix inclusions not working for directories
Oops, the loop was checking the wrong variable! Added a unit test.
This commit is contained in:
parent
aaf46187ab
commit
2ca7cc46c4
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user