diff options
| -rw-r--r-- | go/build.zig | 14 | ||||
| -rw-r--r-- | go/typdown_test.go | 13 |
2 files changed, 26 insertions, 1 deletions
diff --git a/go/build.zig b/go/build.zig index 5e6b59d..a448636 100644 --- a/go/build.zig +++ b/go/build.zig @@ -24,8 +24,20 @@ pub fn build(b: *std.Build) !void { if (optimize != .Debug) try flags.appendSlice(b.allocator, " -s"); const go_build = b.addSystemCommand(&[_][]const u8{ "go", "build", - "-ldflags", try flags.toOwnedSlice(b.allocator), + "-ldflags", flags.items, ".", }); b.getInstallStep().dependOn(&go_build.step); + + const race = b.option(bool, "race", "Run tests with -race") orelse false; + const go_test = b.addSystemCommand(&[_][]const u8{ + "go", "test", + "-ldflags", flags.items, + "-v", + }); + if (race) go_test.addArg("-race"); + go_test.addArg("./..."); + + const test_step = b.step("test", "Run tests"); + test_step.dependOn(&go_test.step); } diff --git a/go/typdown_test.go b/go/typdown_test.go new file mode 100644 index 0000000..c1d8985 --- /dev/null +++ b/go/typdown_test.go @@ -0,0 +1,13 @@ +package typdown + +import "testing" + +func TestParse(t *testing.T) { + res, err := Parse("hello world") + if err != nil { + t.Fatal(err) + } + if res != `<p>hello world</p>` { + t.Errorf("invalid result: %s", res) + } +} |
