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"); const std = @import("std");
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const use_llvm = true;
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("ink", .{ const mod = b.addModule("ink", .{
@ -32,13 +34,29 @@ pub fn build(b: *std.Build) void {
const mod_tests = b.addTest(.{ const mod_tests = b.addTest(.{
.root_module = mod, .root_module = mod,
.use_llvm = use_llvm,
.use_lld = use_llvm,
}); });
const run_mod_tests = b.addRunArtifact(mod_tests); const run_mod_tests = b.addRunArtifact(mod_tests);
const exe_tests = b.addTest(.{ const exe_tests = b.addTest(.{
.root_module = exe.root_module, .root_module = exe.root_module,
.use_llvm = use_llvm,
.use_lld = use_llvm,
}); });
const run_exe_tests = b.addRunArtifact(exe_tests); const run_exe_tests = b.addRunArtifact(exe_tests);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step); test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_exe_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);
} }

View file

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
const fatal = std.process.fatal; const fatal = std.process.fatal;
const ink = @import("root.zig"); const ink = @import("../root.zig");
const Options = struct { const Options = struct {
input_reader: *std.Io.Reader, input_reader: *std.Io.Reader,

View file

@ -6,5 +6,5 @@ test {
_ = tokenizer; _ = tokenizer;
_ = Ast; _ = Ast;
_ = Story; _ = Story;
_ = @import("runtime_tests.zig"); _ = @import("Story/runtime_tests.zig");
} }