add runner test + 'zig build test' subcommand
This commit is contained in:
parent
704eaac081
commit
9fd41a61bf
27
build.zig
27
build.zig
|
@ -1,24 +1,35 @@
|
||||||
|
const builds = @import("std").build;
|
||||||
const Builder = @import("std").build.Builder;
|
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 {
|
pub fn build(b: *Builder) void {
|
||||||
const mode = b.standardReleaseOptions();
|
const mode = b.standardReleaseOptions();
|
||||||
const exe = b.addExecutable("scritcher", "src/main.zig");
|
const exe = b.addExecutable("scritcher", "src/main.zig");
|
||||||
exe.setBuildMode(mode);
|
exe.setBuildMode(mode);
|
||||||
exe.install();
|
exe.install();
|
||||||
|
|
||||||
exe.linkSystemLibrary("lilv-0");
|
setupLinks(exe);
|
||||||
exe.linkSystemLibrary("sndfile");
|
|
||||||
exe.linkSystemLibrary("c");
|
|
||||||
|
|
||||||
exe.linkSystemLibrary("GraphicsMagickWand");
|
const test_obj_step = b.addTest("src/main.zig");
|
||||||
exe.linkSystemLibrary("GraphicsMagick");
|
setupLinks(test_obj_step);
|
||||||
|
|
||||||
exe.addIncludeDir("/usr/include/lilv-0");
|
|
||||||
exe.addIncludeDir("/usr/include/GraphicsMagick");
|
|
||||||
|
|
||||||
const run_cmd = exe.run();
|
const run_cmd = exe.run();
|
||||||
run_cmd.step.dependOn(b.getInstallStep());
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
run_step.dependOn(&run_cmd.step);
|
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 CommandList = std.ArrayList(*Command);
|
||||||
pub const ArgList = std.ArrayList([]const u8);
|
pub const ArgList = std.ArrayList([]const u8);
|
||||||
|
|
||||||
pub const PluginKeywords = [_]CommandType{ .Amp, .RFlanger };
|
|
||||||
pub const KeywordMap = std.AutoHashMap([]const u8, CommandType);
|
pub const KeywordMap = std.AutoHashMap([]const u8, CommandType);
|
||||||
|
|
||||||
pub const Lang = struct {
|
pub const Lang = struct {
|
||||||
|
|
|
@ -4,6 +4,7 @@ const runners = @import("runner.zig");
|
||||||
|
|
||||||
test "scritcher" {
|
test "scritcher" {
|
||||||
_ = @import("lang.zig");
|
_ = @import("lang.zig");
|
||||||
|
_ = @import("runner.zig");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
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 New Issue