nat3Github/zig-lib-update
update tool - zig utility tool for updating remote git dependencies in .zon files
update_tool
gets the hash from your specified branch and runs zig fetch --saveaddTestFolder
all zig files in the specified folder get added as test steps .dependencies = .{
// zig 0.15.1
.update_tool = .{
.url = "git+https://github.com/nat3Github/zig-lib-update#a0ef597d694e1d5f9752841cbf737095bb9c4cf9",
.hash = "update_tool-1.0.0-MwAI-VgaAAB2y3AVVByTm1A6kQhyGB-QzWhGObaJhaKY",
},
// ...
},
const update = @import("update_tool");
const deps: []const update.GitDependency = &.{
.{
// if you leave this the update_tool will update itself
.url = "https://github.com/nat3Github/zig-lib-update",
.branch = "main",
},
.{
// update osmr
.url = "https://github.com/nat3Github/zig-lib-osmr",
.branch = "zig",
},
// add more dependencies here
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
if (update.updateDependencies(b, deps)) return;
zig build -Dupdate
to invoke the update toolconst update = @import("update_tool");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
...
try update.addTestFolder(
b,
// this is the folder path (from build root)
"tests",
optimize,
target,
// add modules that are used in the tests
&.{
.{ .name = "my-module", .mod = my_module_i_want_to_test },
},
// this is the prefix- for the tests
"testprefix",
);
add a new file (first-test.zig) to the test folder
run `zig build testprefix-first-test.zig` to run the tests in first-test.zig
or run `zig build testprefix-all` to run all tests of that folder
this is Public Domain feel free to use it!