commit 34885a21987d932cdd390709661470e9b4241b78
parent a8a432282ba4031a28124ab78715d6e6ab9fcf3f
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date: Thu, 11 May 2023 20:08:44 +0200
Update zigthings
Diffstat:
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/zlox/build.zig b/zlox/build.zig
@@ -27,12 +27,12 @@ pub fn build(b: *std.Build) void {
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`).
- exe.install();
+ b.installArtifact(exe);
- // This *creates* a RunStep in the build graph, to be executed when another
+ // This *creates* a Run step in the build graph, to be executed when another
// step is evaluated that depends on it. The next line below will establish
// such a dependency.
- const run_cmd = exe.run();
+ const run_cmd = b.addRunArtifact(exe);
// By making the run step depend on the install step, it will be run from the
// installation directory rather than directly from within the cache directory.
@@ -52,16 +52,19 @@ pub fn build(b: *std.Build) void {
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
- // Creates a step for unit testing.
- const exe_tests = b.addTest(.{
+ // Creates a step for unit testing. This only builds the test executable
+ // but does not run it.
+ const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
+ const run_unit_tests = b.addRunArtifact(unit_tests);
+
// Similar to creating the run step earlier, this exposes a `test` step to
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
- test_step.dependOn(&exe_tests.step);
+ test_step.dependOn(&run_unit_tests.step);
}
diff --git a/zlox/src/main.zig b/zlox/src/main.zig
@@ -5,7 +5,7 @@ const vm = @import("vm.zig");
pub fn main() anyerror!u8 {
var allocator = std.heap.GeneralPurposeAllocator(.{}){};
- defer std.debug.assert(!allocator.deinit());
+ defer std.debug.assert(allocator.deinit() == std.heap.Check.ok);
var ch = try chunk.Chunk.init(allocator.allocator());
defer ch.deinit();
var VM = vm.VM.init();