| author | |
| committer | |
| log | ea46bd2772daa397e7287352f60da062a1ea4247 |
| tree | a0fd9f6e8ca822ad9e897150af42339f9ba13ca4 |
| parent | 5bbbc8d29906aaaf3ffbe43ee10d9bc7acc321ea |
| signature |
It's now used only by test-cli, so make that clear.5 files changed, 34 insertions(+), 34 deletions(-)
test/cli/options/build.zig created+21| ... | ... | @@ -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 | } |
test/cli/options/src/main.zig created+12| ... | ... | @@ -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 | } |
test/standalone/options/build.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 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 | } |
test/standalone/options/src/main.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 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 | } |
test/tests.zig+1-1| ... | ... | @@ -2204,7 +2204,7 @@ pub fn addCliTests(b: *std.Build) *Step { |
| 2204 | 2204 | "-Dstring=hello", |
| 2205 | 2205 | }); |
| 2206 | 2206 | run_test.addArg("--build-file"); |
| 2207 | run_test.addFileArg(b.path("test/standalone/options/build.zig")); | |
| 2207 | run_test.addFileArg(b.path("test/cli/options/build.zig")); | |
| 2208 | 2208 | run_test.addArg("--cache-dir"); |
| 2209 | 2209 | run_test.addFileArg(.{ .cwd_relative = b.cache_root.join(b.allocator, &.{}) catch @panic("OOM") }); |
| 2210 | 2210 | run_test.setName("test build options"); |