test: add trivial test to make sure we actually build
This commit is contained in:
parent
807702a3b2
commit
12a8e42b8b
2 changed files with 26 additions and 0 deletions
18
build.zig
18
build.zig
|
|
@ -182,11 +182,29 @@ pub fn build(b: *std.Build) void {
|
|||
},
|
||||
});
|
||||
|
||||
const tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/syntax.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.imports = &.{
|
||||
.{ .name = "build_options", .module = options_mod },
|
||||
.{ .name = "cbor", .module = cbor_dep.module("cbor") },
|
||||
.{ .name = "treez", .module = tree_sitter_dep.module("treez") },
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
if (use_tree_sitter) {
|
||||
const ts_bin_query_gen_step = b.addRunArtifact(ts_bin_query_gen);
|
||||
const output = ts_bin_query_gen_step.addOutputFileArg("bin_queries.cbor");
|
||||
syntax_mod.addAnonymousImport("syntax_bin_queries", .{ .root_source_file = output });
|
||||
tests.root_module.addAnonymousImport("syntax_bin_queries", .{ .root_source_file = output });
|
||||
}
|
||||
|
||||
const test_run_cmd = b.addRunArtifact(tests);
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&test_run_cmd.step);
|
||||
}
|
||||
|
||||
fn ts_queryfile(b: *std.Build, dep: *std.Build.Dependency, bin_gen: *std.Build.Step.Compile, comptime sub_path: []const u8) void {
|
||||
|
|
|
|||
|
|
@ -482,3 +482,11 @@ pub fn count_error_nodes(self: *const Self) usize {
|
|||
};
|
||||
return error_count;
|
||||
}
|
||||
|
||||
test "simple build and link test" {
|
||||
const zig_file_type = @import("file_type.zig").get_by_name_static("zig") orelse return error.TestFailed;
|
||||
const query_cache = try QueryCache.create(std.testing.io, std.testing.allocator, .{});
|
||||
defer query_cache.deinit();
|
||||
const syntax = try create(zig_file_type, std.testing.allocator, query_cache);
|
||||
_ = syntax;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue