How to enable more logging and disable caching with "zig build test"?

By default zig build test caches and does not run the tests, unless you set has_side_effects to true.
Example code:

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const tests = b.addTest(.{
        .root_source_file = .{ .path = "src/decimal.zig" },
        .target = target,
        .optimize = optimize,
        .test_runner = "test_runner.zig",
    });
    const run_tests = b.addRunArtifact(tests);
    run_tests.has_side_effects = true;
    const test_step = b.step("test", "Run decimal library tests");
    test_step.dependOn(&run_tests.step);
}
2 Likes