chore: configure kcov for test coverage

This commit is contained in:
Brett Broadhurst 2026-03-18 03:57:02 -06:00
parent 517eae1481
commit d4546d58be
Failed to generate hash of commit
9 changed files with 20 additions and 2 deletions

View file

@ -1,6 +1,8 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const use_llvm = true;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("ink", .{
@ -32,13 +34,29 @@ pub fn build(b: *std.Build) void {
const mod_tests = b.addTest(.{
.root_module = mod,
.use_llvm = use_llvm,
.use_lld = use_llvm,
});
const run_mod_tests = b.addRunArtifact(mod_tests);
const exe_tests = b.addTest(.{
.root_module = exe.root_module,
.use_llvm = use_llvm,
.use_lld = use_llvm,
});
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);
const run_cover = b.addSystemCommand(&.{
"kcov",
"--clean",
"--include-pattern=src/",
b.pathJoin(&.{ b.install_path, "cover" }),
});
run_cover.addArtifactArg(mod_tests);
const cover_step = b.step("cover", "Generate test coverage report");
cover_step.dependOn(&run_cover.step);
}