-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
63 lines (46 loc) · 1.86 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Build script for ztap
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const ztap_module = b.addModule("ztap", .{
.root_source_file = b.path("src/ztap.zig"),
.target = target,
.optimize = optimize,
});
_ = ztap_module; // autofix
const test_filters = b.option(
[]const []const u8,
"test-filter",
"Skip tests that do not match any filter",
) orelse &[0][]const u8{};
const module_unit_tests = b.addTest(.{
.root_source_file = b.path("src/ztap.zig"),
.target = target,
.optimize = optimize,
.filters = test_filters,
});
const run_module_unit_tests = b.addRunArtifact(module_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_module_unit_tests.step);
const addOutputDirectoryArg = comptime if (@import("builtin").zig_version.order(.{ .major = 0, .minor = 13, .patch = 0 }) == .lt)
std.Build.Step.Run.addOutputFileArg
else
std.Build.Step.Run.addOutputDirectoryArg;
const run_kcov = b.addSystemCommand(&.{
"kcov",
"--clean",
"--exclude-line=unreachable,expect(false)",
});
run_kcov.addPrefixedDirectoryArg("--include-pattern=", b.path("."));
const coverage_output = addOutputDirectoryArg(run_kcov, ".");
run_kcov.addArtifactArg(module_unit_tests);
run_kcov.enableTestRunnerMode();
const install_coverage = b.addInstallDirectory(.{
.source_dir = coverage_output,
.install_dir = .{ .custom = "coverage" },
.install_subdir = "",
});
const coverage_step = b.step("coverage", "Generate coverage (kcov must be installed)");
coverage_step.dependOn(&install_coverage.step);
}