From f406495e22e82f18382cbce72a5d2a3608a1923c Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Thu, 4 Dec 2025 18:28:51 -0500 Subject: [PATCH] Add test build with just command --- build.zig | 22 ++++++++++++++++++++++ justfile | 3 +++ 2 files changed, 25 insertions(+) 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