add runner test + 'zig build test' subcommand
This commit is contained in:
parent
704eaac081
commit
9fd41a61bf
4 changed files with 38 additions and 9 deletions
27
build.zig
27
build.zig
|
@ -1,24 +1,35 @@
|
|||
const builds = @import("std").build;
|
||||
const Builder = @import("std").build.Builder;
|
||||
|
||||
fn setupLinks(step: *builds.LibExeObjStep) void {
|
||||
step.linkSystemLibrary("lilv-0");
|
||||
step.linkSystemLibrary("sndfile");
|
||||
step.linkSystemLibrary("c");
|
||||
|
||||
step.linkSystemLibrary("GraphicsMagickWand");
|
||||
step.linkSystemLibrary("GraphicsMagick");
|
||||
|
||||
step.addIncludeDir("/usr/include/lilv-0");
|
||||
step.addIncludeDir("/usr/include/GraphicsMagick");
|
||||
}
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
const exe = b.addExecutable("scritcher", "src/main.zig");
|
||||
exe.setBuildMode(mode);
|
||||
exe.install();
|
||||
|
||||
exe.linkSystemLibrary("lilv-0");
|
||||
exe.linkSystemLibrary("sndfile");
|
||||
exe.linkSystemLibrary("c");
|
||||
setupLinks(exe);
|
||||
|
||||
exe.linkSystemLibrary("GraphicsMagickWand");
|
||||
exe.linkSystemLibrary("GraphicsMagick");
|
||||
|
||||
exe.addIncludeDir("/usr/include/lilv-0");
|
||||
exe.addIncludeDir("/usr/include/GraphicsMagick");
|
||||
const test_obj_step = b.addTest("src/main.zig");
|
||||
setupLinks(test_obj_step);
|
||||
|
||||
const run_cmd = exe.run();
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&test_obj_step.step);
|
||||
}
|
||||
|
|
|
@ -127,7 +127,6 @@ pub const Command = struct {
|
|||
pub const CommandList = std.ArrayList(*Command);
|
||||
pub const ArgList = std.ArrayList([]const u8);
|
||||
|
||||
pub const PluginKeywords = [_]CommandType{ .Amp, .RFlanger };
|
||||
pub const KeywordMap = std.AutoHashMap([]const u8, CommandType);
|
||||
|
||||
pub const Lang = struct {
|
||||
|
|
|
@ -4,6 +4,7 @@ const runners = @import("runner.zig");
|
|||
|
||||
test "scritcher" {
|
||||
_ = @import("lang.zig");
|
||||
_ = @import("runner.zig");
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
|
|
|
@ -469,3 +469,21 @@ pub const Runner = struct {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
test "running noop" {
|
||||
const allocator = std.heap.direct_allocator;
|
||||
var cmds = lang.CommandList.init(allocator);
|
||||
defer cmds.deinit();
|
||||
|
||||
var cmd_ptr = try allocator.create(lang.Command);
|
||||
cmd_ptr.* = lang.Command{
|
||||
.command = .Noop,
|
||||
.args = lang.ArgList.init(allocator),
|
||||
};
|
||||
try cmds.append(cmd_ptr);
|
||||
|
||||
var runner = Runner.init(allocator);
|
||||
defer runner.deinit();
|
||||
|
||||
try runner.runCommands(cmds, false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue