Skip to content

Commit

Permalink
ops: fix kcov integration
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesrocket committed Jun 20, 2024
1 parent 470ac33 commit e224f26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
directory: zig-out/coverage/kcov-merged
directory: kcov-out
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
37 changes: 9 additions & 28 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,16 @@ pub fn build(b: *std.Build) void {

test_step.dependOn(&b.addRunArtifact(integration_tests).step);

const coverage_step = b.step("coverage", "Generate test coverage (kcov)");
const merge_step = std.Build.Step.Run.create(b, "merge coverage");
merge_step.addArgs(&.{ "kcov", "--merge" });
merge_step.rename_step_with_output_arg = false;
const merged_coverage_output = merge_step.addOutputFileArg(".");

{
const kcov_collect = std.Build.Step.Run.create(b, "collect coverage");
kcov_collect.addArgs(&.{ "kcov", "--collect-only" });
kcov_collect.addPrefixedDirectoryArg("--include-pattern=", b.path("src"));
merge_step.addDirectoryArg(kcov_collect.addOutputFileArg(unit_tests.name));
kcov_collect.addArtifactArg(unit_tests);
kcov_collect.enableTestRunnerMode();
}
const merge_step = b.addSystemCommand(&.{ "kcov", "--merge", "kcov-out", "kcov-test", "kcov-unit" });

{
const kcov_collect = std.Build.Step.Run.create(b, "collect coverage");
kcov_collect.addArgs(&.{ "kcov", "--collect-only" });
kcov_collect.addPrefixedDirectoryArg("--include-pattern=", b.path("src"));
merge_step.addDirectoryArg(kcov_collect.addOutputFileArg(integration_tests.name));
kcov_collect.addArtifactArg(integration_tests);
kcov_collect.enableTestRunnerMode();
}
const kcov_int = b.addSystemCommand(&.{ "kcov", "kcov-test", "--include-path=src" });
kcov_int.addArtifactArg(integration_tests);
merge_step.step.dependOn(&kcov_int.step);

const install_coverage = b.addInstallDirectory(.{
.source_dir = merged_coverage_output,
.install_dir = .{ .custom = "coverage" },
.install_subdir = "",
});
const kcov_unit = b.addSystemCommand(&.{ "kcov", "kcov-unit", "--include-path=src" });
kcov_unit.addArtifactArg(unit_tests);
merge_step.step.dependOn(&kcov_unit.step);

coverage_step.dependOn(&install_coverage.step);
const coverage_step = b.step("coverage", "Generate test coverage (kcov)");
coverage_step.dependOn(&merge_step.step);
}

0 comments on commit e224f26

Please sign in to comment.