diff --git a/build.zig b/build.zig index 24171cd..bb3b08b 100644 --- a/build.zig +++ b/build.zig @@ -31,4 +31,26 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "run the game"); run_step.dependOn(&run_cmd.step); + + // test step (doesn't need raylib) + const test_step = b.step("test", "run unit tests"); + + const test_files = [_][]const u8{ + "src/fixed.zig", + "src/trig.zig", + "src/terrain.zig", + "src/game.zig", + }; + + for (test_files) |file| { + const unit_test = b.addTest(.{ + .root_module = b.createModule(.{ + .root_source_file = b.path(file), + .target = target, + .optimize = optimize, + }), + }); + const run_test = b.addRunArtifact(unit_test); + test_step.dependOn(&run_test.step); + } } diff --git a/justfile b/justfile index cd578b5..90b2629 100644 --- a/justfile +++ b/justfile @@ -34,3 +34,6 @@ clean: # check for compile errors without building check: zig build --summary all 2>&1 | head -50 + +test: + zig build test