Artifact 20fe82ab431c8ed12a5ede5985d4e8f31b56883a0954d3b6b7874110fb6bdfb4:
- File
build.zig
— part of check-in
[c4c4ad80d1]
at
2026-07-09 19:55:09
on branch trunk
— Wire up a seeded fuzz build step and give apply() and targetSize() fuzz coverage
Add zig build fuzz, dispatching to named seeded targets in fuzz_tests.zig via a tuple->FieldEnum table, plus bench/smoke stubs that fail until those milestones land. delta_fuzz.zig parameterizes the existing apply/create/ decodeInt property checks by seed and round count for an out-of-band runner. delta.zig gains an allocation-failure test for apply() mirroring create()'s, and a targetSize() garbage-never-crashes block. (user: dmestas, size: 2728) [annotate] [blame] [check-ins using]
const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // The zit library: a Zig implementation of the Fossil formats and protocol // as specified by the four RFC drafts in docs/rfcs/. const mod = b.addModule("zit", .{ .root_source_file = b.path("src/root.zig"), .target = target, }); // The `zit` command-line tool. const exe = b.addExecutable(.{ .name = "zit", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "zit", .module = mod }, }, }), }); b.installArtifact(exe); // `zig build run -- <args>` const run_step = b.step("run", "Run the zit CLI"); const run_cmd = b.addRunArtifact(exe); run_step.dependOn(&run_cmd.step); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| run_cmd.addArgs(args); // `zig build test` — runs library + CLI unit tests. const test_step = b.step("test", "Run unit tests"); const mod_tests = b.addTest(.{ .root_module = mod }); test_step.dependOn(&b.addRunArtifact(mod_tests).step); const exe_tests = b.addTest(.{ .root_module = exe.root_module }); test_step.dependOn(&b.addRunArtifact(exe_tests).step); // `zig build fuzz -- <target> [--seed N] [--rounds N]` — seeded deterministic // fuzz targets, driven in a loop by an out-of-band runner; not part of `test`. const fuzz_exe = b.addExecutable(.{ .name = "fuzz", .root_module = b.createModule(.{ .root_source_file = b.path("src/fuzz_tests.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "zit", .module = mod }}, }), }); const fuzz_step = b.step("fuzz", "Run a seeded fuzz target (zig build fuzz -- <target> --seed N)"); const fuzz_run = b.addRunArtifact(fuzz_exe); if (b.args) |args| fuzz_run.addArgs(args); fuzz_step.dependOn(&fuzz_run.step); // `bench` and `smoke` are wired at later milestones (a benchmark suite, // and a bounded Fossil interop check run only at layer milestones); until // then they exist as named steps that fail loudly rather than silently // passing. const bench_step = b.step("bench", "Benchmarks"); bench_step.dependOn(&b.addFail("bench: no benchmark exists yet").step); const smoke_step = b.step("smoke", "Fossil interop smoke check (milestone-manual)"); smoke_step.dependOn(&b.addFail("smoke: wired at layer milestones only").step); }