@@ -27,12 +27,12 @@ pub fn build(b: *std.Build) void {
27
27
// This declares intent for the executable to be installed into the
28
28
// standard location when the user invokes the "install" step (the default
29
29
// step when running `zig build`).
30
- exe . install ( );
30
+ b . installArtifact ( exe );
31
31
32
32
// This *creates* a RunStep in the build graph, to be executed when another
33
33
// step is evaluated that depends on it. The next line below will establish
34
34
// such a dependency.
35
- const run_cmd = exe . run ( );
35
+ const run_cmd = b . addRunArtifact ( exe );
36
36
37
37
// By making the run step depend on the install step, it will be run from the
38
38
// installation directory rather than directly from within the cache directory.
@@ -52,16 +52,19 @@ pub fn build(b: *std.Build) void {
52
52
const run_step = b .step ("run" , "Run the app" );
53
53
run_step .dependOn (& run_cmd .step );
54
54
55
- // Creates a step for unit testing.
56
- const exe_tests = b .addTest (.{
55
+ // Creates a step for unit testing. This only builds the test executable
56
+ // but does not run it.
57
+ const unit_tests = b .addTest (.{
57
58
.root_source_file = .{ .path = "src/main.zig" },
58
59
.target = target ,
59
60
.optimize = optimize ,
60
61
});
61
62
63
+ const run_unit_tests = b .addRunArtifact (unit_tests );
64
+
62
65
// Similar to creating the run step earlier, this exposes a `test` step to
63
66
// the `zig build --help` menu, providing a way for the user to request
64
67
// running the unit tests.
65
68
const test_step = b .step ("test" , "Run unit tests" );
66
- test_step .dependOn (& exe_tests .step );
69
+ test_step .dependOn (& run_unit_tests .step );
67
70
}
0 commit comments