Skip to content

Commit dde0ac6

Browse files
committed
Add Zig module and set test target
1 parent 700c3c0 commit dde0ac6

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

.github/workflows/docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
version: master
2020

2121
- name: Test
22-
run: zig build test -Demit_docs
22+
run: zig build test -Demit-docs
2323

2424
- name: Publish
2525
if: success()

build.zig

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
const std = @import("std");
22

33
pub fn build(b: *std.Build) void {
4-
const lib_tests = b.addTest(.{
5-
.root_source_file = .{ .path = "src/main.zig" },
6-
.optimize = b.standardOptimizeOption(.{}),
4+
const target = b.standardTargetOptions(.{});
5+
const optimize = b.standardOptimizeOption(.{});
6+
const test_filter = b.option([]const u8, "test-filter", "Filter the executed library tests");
7+
const emit_docs = b.option(bool, "emit-docs", "Build library documentation") orelse false;
8+
9+
const module = b.addModule("hzzp", .{
10+
.source_file = .{ .path = "src/main.zig" },
711
});
8-
const run_tests = b.addRunArtifact(lib_tests);
912

10-
const tests = b.step("test", "Run all library tests");
11-
tests.dependOn(&run_tests.step);
13+
const test_compile_step = b.addTest(.{
14+
.root_source_file = module.source_file,
15+
.target = target,
16+
.optimize = optimize,
17+
});
18+
test_compile_step.setFilter(test_filter);
1219

13-
const docs = b.option(bool, "emit_docs", "Build library documentation") orelse false;
20+
const test_run_step = b.addRunArtifact(test_compile_step);
1421

15-
if (docs)
16-
lib_tests.emit_docs = .emit;
22+
const test_step = b.step("test", "Run all library tests");
23+
if (emit_docs) {
24+
test_compile_step.emit_docs = .emit;
25+
test_step.dependOn(&test_compile_step.step);
26+
} else {
27+
test_step.dependOn(&test_run_step.step);
28+
}
1729
}

0 commit comments

Comments
 (0)