build: update

This commit is contained in:
Arran Ireland
2025-01-05 22:15:37 +00:00
parent 108460fbb2
commit 43ddbecc24
3 changed files with 76 additions and 10 deletions

View File

@@ -4,13 +4,66 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const tests = b.addTest(.{
.root_source_file = b.path("src/reticulum.zig"),
.target = target,
.optimize = optimize,
});
const core = .{
.name = "reticulum",
.module = b.addModule("reticulum-core", .{
.root_source_file = b.path("core/reticulum.zig"),
.target = target,
.optimize = optimize,
}),
};
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run tests.");
test_step.dependOn(&run_tests.step);
const test_step = b.step("test", "Run all tests.");
// Unit tests.
{
const unit_tests_step = b.step("unit-tests", "Run unit tests.");
test_step.dependOn(unit_tests_step);
const t_app = b.addTest(.{
.name = "app",
.root_source_file = b.path("app/main.zig"),
.target = target,
.optimize = optimize,
});
unit_tests_step.dependOn(&b.addRunArtifact(t_app).step);
const t_core = b.addTest(.{
.name = "core",
.root_source_file = b.path("core/reticulum.zig"),
.target = target,
.optimize = optimize,
});
unit_tests_step.dependOn(&b.addRunArtifact(t_core).step);
}
// Integration tests.
{
const integration_tests_step = b.step("integration-tests", "Run integration tests.");
test_step.dependOn(integration_tests_step);
const fixtures = b.createModule(.{
.root_source_file = b.path("test/fixtures.zig"),
.target = target,
.optimize = optimize,
.imports = &.{core},
});
const integration_tests = .{
"announce",
};
// const ohsnap = b.dependency("ohsnap", .{});s
inline for (integration_tests) |name| {
const t = b.addTest(.{
.name = name,
.root_source_file = b.path("test/integration/" ++ name ++ ".zig"),
.target = target,
.optimize = optimize,
});
t.root_module.addImport("fixtures", fixtures);
t.root_module.addImport(core.name, core.module);
integration_tests_step.dependOn(&b.addRunArtifact(t).step);
}
}
}

View File

@@ -1,6 +1,19 @@
.{
.name = "reticulum",
.version = "0.1.0",
.dependencies = .{},
.paths = .{"."},
.minimum_zig_version = "0.13.0",
.paths = .{
"build.zig",
"build.zig.zon",
"LICENSE",
"README.md",
"src/",
},
.dependencies = .{
// TODO: Use in integration testing.
// .ohsnap = .{
// .url = "https://github.com/mnemnion/ohsnap/archive/refs/tags/v0.3.1.tar.gz",
// .hash = "1220380908ede3cce3dafb2e69b4994a3df55a468597d9d571a495c66ad38ac73ef8",
// },
},
}

View File