mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
The previous logic here was trying to assume that custom test runners never used `std.zig.Server` to communicate with the build runner; however, it was flawed, because modifying the `test_runner` field on `Step.Compile` would not update this flag. That might have been intentional (allowing a way for the user to specify a custom test runner which *does* use the compiler server protocol), but if so, it was a flawed API, since it was too easy to update one field without updating the other. Instead, bundle these two pieces of state into a new type `std.Build.Step.Compile.TestRunner`. When passing a custom test runner, you are now *provided* to specify whether it is a "simple" runner, or whether it uses the compiler server protocol. This is a breaking change, but is unlikely to affect many people, since custom test runners are seldom used in the wild.
18 lines
510 B
Zig
18 lines
510 B
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const test_step = b.step("test", "Test the program");
|
|
b.default_step = test_step;
|
|
|
|
const test_exe = b.addTest(.{ .root_module = b.createModule(.{
|
|
.target = b.graph.host,
|
|
.root_source_file = b.path("test.zig"),
|
|
}) });
|
|
test_exe.test_runner = .{
|
|
.path = b.path("test_runner.zig"),
|
|
.mode = .simple,
|
|
};
|
|
|
|
const test_run = b.addRunArtifact(test_exe);
|
|
test_step.dependOn(&test_run.step);
|
|
}
|