authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-02-15 22:08:03 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-02-15 22:08:03 -08:00
loge514a3e79fb783333f3856d4cf1b56c822b97df0
tree6e48e134cb11fa3a7e00942848aad4d930ad5364
parent5f01135730eb556494e35f46b70b65e799ae1459

add tests and update to zig 0.13


3 files changed, 18 insertions(+), 21 deletions(-)

build.zig+9-18
......@@ -6,26 +6,17 @@ pub fn build(b: *std.Build) void {
66 const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug;
77 const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false;
88
9 const exe = b.addExecutable(.{
10 .name = "zig-flag",
11 .root_source_file = b.path("src/main.zig"),
9 const tests = b.addTest(.{
10 .root_source_file = b.path("test.zig"),
1211 .target = target,
1312 .optimize = mode,
1413 });
15 deps.addAllTo(exe);
16 exe.use_llvm = !disable_llvm;
17 exe.use_lld = !disable_llvm;
18 b.installArtifact(exe);
14 deps.addAllTo(tests);
15 tests.use_llvm = !disable_llvm;
16 tests.use_lld = !disable_llvm;
1917
20 const run_cmd = b.addRunArtifact(exe);
21 run_cmd.step.dependOn(b.getInstallStep());
22 if (b.args) |args| {
23 run_cmd.addArgs(args);
24 }
25
26 const run_step = b.step("run", "Run the app");
27 run_step.dependOn(&run_cmd.step);
28
29 const test_step = b.step("test", "dummy test step to pass CI checks");
30 _ = test_step;
18 const test_step = b.step("test", "Run all library tests");
19 const tests_run = b.addRunArtifact(tests);
20 tests_run.has_side_effects = true;
21 test_step.dependOn(&tests_run.step);
3122}
src/lib.zig+3-3
......@@ -67,7 +67,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator {
6767 }
6868 }
6969 std.log.err("Unrecognized argument: {s}{s}", .{ dash, name });
70 std.os.exit(1);
70 std.posix.exit(1);
7171 }
7272 return argiter;
7373}
......@@ -78,7 +78,7 @@ pub fn parseEnv() !void {
7878 for (singles.keys(), singles.values()) |k, *v| {
7979 const u = try fixNameForEnv(alloc, k);
8080 defer alloc.free(u);
81 if (std.os.getenv(u)) |value| {
81 if (std.posix.getenv(u)) |value| {
8282 v.* = value;
8383 }
8484 }
......@@ -89,7 +89,7 @@ pub fn parseEnv() !void {
8989 defer alloc.free(u);
9090 const w = try std.fmt.allocPrint(alloc, "{s}_{d}", .{ u, n });
9191 defer alloc.free(w);
92 if (std.os.getenv(w)) |value| {
92 if (std.posix.getenv(w)) |value| {
9393 try v.append(value);
9494 continue;
9595 }
test.zig created+6
......@@ -0,0 +1,6 @@
1const std = @import("std");
2const flag = @import("flag");
3
4test {
5 std.testing.refAllDeclsRecursive(flag);
6}