From 1f19d4d7063527c03de16ca32e314c71df2cf1e8 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 1 Jan 2025 20:52:25 -0800 Subject: [PATCH] add tests --- build.zig | 12 ++++++++++++ test.zig | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test.zig diff --git a/build.zig b/build.zig index 413156b3c79f2166d14b9713ab938f64e7acb17a..f1e34313a58442029b63added5e6767a8f2c7edc 100644 --- a/build.zig +++ b/build.zig @@ -22,4 +22,16 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); + + const tests = b.addTest(.{ + .root_source_file = b.path("test.zig"), + .target = target, + .optimize = mode, + }); + deps.addAllTo(tests); + + const test_step = b.step("test", "Run all library tests"); + const tests_run = b.addRunArtifact(tests); + tests_run.has_side_effects = true; + test_step.dependOn(&tests_run.step); } diff --git a/test.zig b/test.zig new file mode 100644 index 0000000000000000000000000000000000000000..31a3b86e29d175fac1633393d73f7e4c05a73850 --- /dev/null +++ b/test.zig @@ -0,0 +1,11 @@ +const std = @import("std"); +const inquirer = @import("inquirer"); + +test { + // ensure these have no compile errors + // but don't write anything to stdout/stderr + _ = &inquirer.answer; + _ = &inquirer.forEnum; + _ = &inquirer.forString; + _ = &inquirer.forConfirm; +} -- 2.54.0