Skip to content

Commit 5bbbc8d

Browse files
committed
Revert "test: remove standalone options test"
This reverts commit d9cd4d0. Turns out Jacob restored this test as part of test-cli in cdba1d5.
1 parent c4b7caa commit 5bbbc8d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/standalone/options/build.zig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const main = b.addTest(.{ .root_module = b.createModule(.{
5+
.root_source_file = b.path("src/main.zig"),
6+
.target = b.graph.host,
7+
.optimize = .Debug,
8+
}) });
9+
10+
const options = b.addOptions();
11+
main.root_module.addOptions("build_options", options);
12+
options.addOption(bool, "bool_true", b.option(bool, "bool_true", "t").?);
13+
options.addOption(bool, "bool_false", b.option(bool, "bool_false", "f").?);
14+
options.addOption(u32, "int", b.option(u32, "int", "i").?);
15+
const E = enum { one, two, three };
16+
options.addOption(E, "e", b.option(E, "e", "e").?);
17+
options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?);
18+
19+
const test_step = b.step("test", "Run unit tests");
20+
test_step.dependOn(&b.addRunArtifact(main).step);
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const std = @import("std");
2+
const assert = std.debug.assert;
3+
4+
const build_options = @import("build_options");
5+
6+
test "build options" {
7+
comptime assert(build_options.bool_true);
8+
comptime assert(!build_options.bool_false);
9+
comptime assert(build_options.int == 1234);
10+
comptime assert(build_options.e == .two);
11+
comptime assert(std.mem.eql(u8, build_options.string, "hello"));
12+
}

0 commit comments

Comments
 (0)