From d56010b0648c7230dd47fcf5b73fc49a7697c326 Mon Sep 17 00:00:00 2001 From: Overlord Date: Thu, 6 Aug 2026 10:48:43 +0200 Subject: [PATCH] refactor build system: separate test module and streamline test dependencies --- build.zig | 18 ++++++++++-------- src/root.zig | 8 +++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/build.zig b/build.zig index b15c7de..71a56ea 100644 --- a/build.zig +++ b/build.zig @@ -34,9 +34,18 @@ pub fn build(b: *std.Build) void .target = target, }); + const test_mod = b.createModule(.{ + .root_source_file = b.path("src/root.zig"), + .target = target, + .link_libc = true, + }); + mod.addImport("toml", toml_dep.module("toml")); mod.addImport("args", args_dep.module("args")); + test_mod.addImport("toml", toml_dep.module("toml")); + test_mod.addImport("args", args_dep.module("args")); + const exe = b.addExecutable(.{ .name = "zocket", .root_module = b.createModule(.{ @@ -66,20 +75,13 @@ pub fn build(b: *std.Build) void } const mod_tests = b.addTest(.{ - .root_module = mod, + .root_module = test_mod, }); const run_mod_tests = b.addRunArtifact(mod_tests); - const exe_tests = b.addTest(.{ - .root_module = exe.root_module, - }); - - const run_exe_tests = b.addRunArtifact(exe_tests); - const test_step = b.step("test", "Run tests"); test_step.dependOn(&run_mod_tests.step); - test_step.dependOn(&run_exe_tests.step); } fn getGitVersion(b: *std.Build) []const u8 diff --git a/src/root.zig b/src/root.zig index b7e99f1..2c02058 100644 --- a/src/root.zig +++ b/src/root.zig @@ -8,8 +8,10 @@ pub const memory = @import("memory/util.zig"); pub const signals = @import("signals/models.zig"); pub const logging = @import("logging/log.zig"); +// + +const std = @import("std"); + test { - _ = config; - _ = memory; - _ = signals; + std.testing.refAllDecls(@This()); }