const std = @import("std");
const tests = @import("tests-tmp.zig");
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(tests.addCliTests(b));
}
const std = @import("std");
const Step = std.Build.Step;
pub fn addCliTests(b: *std.Build) *Step {
const step = b.step("test-cli", "Test the command line interface");
const s = std.fs.path.sep_str;
// Test `zig init-lib`.
const tmp_path = b.makeTempPath();
const init_lib = b.addSystemCommand(&.{ b.zig_exe, "init-lib" });
init_lib.cwd = tmp_path;
init_lib.setName("zig init-lib");
init_lib.expectStdOutEqual("");
init_lib.expectStdErrEqual("info: Created build.zig\n" ++
"info: Created src" ++ s ++ "main.zig\n" ++
"info: Next, try `zig build --help` or `zig build test`\n");
const run_test = b.addSystemCommand(&.{ b.zig_exe, "build", "test" });
run_test.cwd = tmp_path;
run_test.setName("zig build test");
run_test.expectStdOutEqual("");
run_test.step.dependOn(&init_lib.step);
const cleanup = b.addRemoveDirTree(tmp_path);
cleanup.step.dependOn(&run_test.step);
step.dependOn(&cleanup.step);
return step;
}
strace -f -v -s 80 build/stage3/bin/zig build --build-file build-tmp.zig test &> /tmp/strace