refactor build system: separate test module and streamline test dependencies
This commit is contained in:
18
build.zig
18
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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user