|
1 | 1 | const std = @import("std");
|
2 | 2 |
|
3 | 3 | 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" }, |
7 | 11 | });
|
8 |
| - const run_tests = b.addRunArtifact(lib_tests); |
9 | 12 |
|
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); |
12 | 19 |
|
13 |
| - const docs = b.option(bool, "emit_docs", "Build library documentation") orelse false; |
| 20 | + const test_run_step = b.addRunArtifact(test_compile_step); |
14 | 21 |
|
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 | + } |
17 | 29 | }
|
0 commit comments