mirror of
https://github.com/ziglang/zig.git
synced 2026-01-18 13:25:15 +00:00
This is fairly straightforward; the actual compiler changes are limited to the CLI, since `Compilation` already supports this combination. A new `std.Build` API is introduced to allow representing this. By passing the `emit_object` option to `std.Build.addTest`, you get a `Step.Compile` which emits an object file; you can then use that as you would any other object, such as either installing it for external use, or linking it into another step. A standalone test is added to cover the build system API. It builds a test into an object, and links it into a final executable, which it then runs. Using this build system mechanism prevents the build system from noticing that you're running a `zig test`, so the build runner and test runner do not communicate over stdio. However, that's okay, because the real-world use cases for this feature don't want to do that anyway! Resolves: #23374
18 lines
232 B
Zig
18 lines
232 B
Zig
test {
|
|
try std.testing.expect(true);
|
|
}
|
|
|
|
test "equality" {
|
|
try std.testing.expect(one() == 1);
|
|
}
|
|
|
|
test "arithmetic" {
|
|
try std.testing.expect(one() + 2 == 3);
|
|
}
|
|
|
|
fn one() u32 {
|
|
return 1;
|
|
}
|
|
|
|
const std = @import("std");
|