| author | |
| committer | |
| log | e514a3e79fb783333f3856d4cf1b56c822b97df0 |
| tree | 6e48e134cb11fa3a7e00942848aad4d930ad5364 |
| parent | 5f01135730eb556494e35f46b70b65e799ae1459 |
3 files changed, 18 insertions(+), 21 deletions(-)
build.zig+9-18| ... | @@ -6,26 +6,17 @@ pub fn build(b: *std.Build) void { | ... | @@ -6,26 +6,17 @@ pub fn build(b: *std.Build) void { |
| 6 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; | 6 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; |
| 7 | const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; | 7 | const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; |
| 8 | 8 | ||
| 9 | const exe = b.addExecutable(.{ | 9 | const tests = b.addTest(.{ |
| 10 | .name = "zig-flag", | 10 | .root_source_file = b.path("test.zig"), |
| 11 | .root_source_file = b.path("src/main.zig"), | ||
| 12 | .target = target, | 11 | .target = target, |
| 13 | .optimize = mode, | 12 | .optimize = mode, |
| 14 | }); | 13 | }); |
| 15 | deps.addAllTo(exe); | 14 | deps.addAllTo(tests); |
| 16 | exe.use_llvm = !disable_llvm; | 15 | tests.use_llvm = !disable_llvm; |
| 17 | exe.use_lld = !disable_llvm; | 16 | tests.use_lld = !disable_llvm; |
| 18 | b.installArtifact(exe); | ||
| 19 | 17 | ||
| 20 | const run_cmd = b.addRunArtifact(exe); | 18 | const test_step = b.step("test", "Run all library tests"); |
| 21 | run_cmd.step.dependOn(b.getInstallStep()); | 19 | const tests_run = b.addRunArtifact(tests); |
| 22 | if (b.args) |args| { | 20 | tests_run.has_side_effects = true; |
| 23 | run_cmd.addArgs(args); | 21 | test_step.dependOn(&tests_run.step); |
| 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; | ||
| 31 | } | 22 | } |
src/lib.zig+3-3| ... | @@ -67,7 +67,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator { | ... | @@ -67,7 +67,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator { |
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | std.log.err("Unrecognized argument: {s}{s}", .{ dash, name }); | 69 | std.log.err("Unrecognized argument: {s}{s}", .{ dash, name }); |
| 70 | std.os.exit(1); | 70 | std.posix.exit(1); |
| 71 | } | 71 | } |
| 72 | return argiter; | 72 | return argiter; |
| 73 | } | 73 | } |
| ... | @@ -78,7 +78,7 @@ pub fn parseEnv() !void { | ... | @@ -78,7 +78,7 @@ pub fn parseEnv() !void { |
| 78 | for (singles.keys(), singles.values()) |k, *v| { | 78 | for (singles.keys(), singles.values()) |k, *v| { |
| 79 | const u = try fixNameForEnv(alloc, k); | 79 | const u = try fixNameForEnv(alloc, k); |
| 80 | defer alloc.free(u); | 80 | defer alloc.free(u); |
| 81 | if (std.os.getenv(u)) |value| { | 81 | if (std.posix.getenv(u)) |value| { |
| 82 | v.* = value; | 82 | v.* = value; |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| ... | @@ -89,7 +89,7 @@ pub fn parseEnv() !void { | ... | @@ -89,7 +89,7 @@ pub fn parseEnv() !void { |
| 89 | defer alloc.free(u); | 89 | defer alloc.free(u); |
| 90 | const w = try std.fmt.allocPrint(alloc, "{s}_{d}", .{ u, n }); | 90 | const w = try std.fmt.allocPrint(alloc, "{s}_{d}", .{ u, n }); |
| 91 | defer alloc.free(w); | 91 | defer alloc.free(w); |
| 92 | if (std.os.getenv(w)) |value| { | 92 | if (std.posix.getenv(w)) |value| { |
| 93 | try v.append(value); | 93 | try v.append(value); |
| 94 | continue; | 94 | continue; |
| 95 | } | 95 | } |
test.zig created+6| ... | @@ -0,0 +1,6 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const flag = @import("flag"); | ||
| 3 | |||
| 4 | test { | ||
| 5 | std.testing.refAllDeclsRecursive(flag); | ||
| 6 | } | ||