mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Revert "test: remove standalone options test"
This reverts commitd9cd4d0876. Turns out Jacob restored this test as part of test-cli incdba1d5.
This commit is contained in:
parent
c4b7caa528
commit
5bbbc8d299
2 changed files with 33 additions and 0 deletions
21
test/standalone/options/build.zig
Normal file
21
test/standalone/options/build.zig
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) void {
|
||||||
|
const main = b.addTest(.{ .root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/main.zig"),
|
||||||
|
.target = b.graph.host,
|
||||||
|
.optimize = .Debug,
|
||||||
|
}) });
|
||||||
|
|
||||||
|
const options = b.addOptions();
|
||||||
|
main.root_module.addOptions("build_options", options);
|
||||||
|
options.addOption(bool, "bool_true", b.option(bool, "bool_true", "t").?);
|
||||||
|
options.addOption(bool, "bool_false", b.option(bool, "bool_false", "f").?);
|
||||||
|
options.addOption(u32, "int", b.option(u32, "int", "i").?);
|
||||||
|
const E = enum { one, two, three };
|
||||||
|
options.addOption(E, "e", b.option(E, "e", "e").?);
|
||||||
|
options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?);
|
||||||
|
|
||||||
|
const test_step = b.step("test", "Run unit tests");
|
||||||
|
test_step.dependOn(&b.addRunArtifact(main).step);
|
||||||
|
}
|
||||||
12
test/standalone/options/src/main.zig
Normal file
12
test/standalone/options/src/main.zig
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const assert = std.debug.assert;
|
||||||
|
|
||||||
|
const build_options = @import("build_options");
|
||||||
|
|
||||||
|
test "build options" {
|
||||||
|
comptime assert(build_options.bool_true);
|
||||||
|
comptime assert(!build_options.bool_false);
|
||||||
|
comptime assert(build_options.int == 1234);
|
||||||
|
comptime assert(build_options.e == .two);
|
||||||
|
comptime assert(std.mem.eql(u8, build_options.string, "hello"));
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue