diff --git a/.build.yml b/.build.yml index c793264..df40ffd 100644 --- a/.build.yml +++ b/.build.yml @@ -19,6 +19,9 @@ tasks: shellcheck -x $(awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(git ls-files)) bazel run //:buildifier git diff --exit-code + - test_native: | + cd bazel-zig-cc; . .envrc + bazel test //... - test_list_toolchains: | cd bazel-zig-cc; . .envrc; echo "Available toolchains:" bazel query @zig_sdk//... | sed -En '/.*_toolchain$/ s/.*:(.*)_toolchain$/\1/p' diff --git a/test/BUILD b/test/BUILD index 00c2c02..acf368b 100644 --- a/test/BUILD +++ b/test/BUILD @@ -18,7 +18,7 @@ go_binary( ) go_test( - name = "test_test", + name = "hello_test", srcs = ["hello_test.go"], - embed = [":test_lib"], + embed = [":hello_lib"], ) diff --git a/test/hello.go b/test/hello.go index 6d042bd..f998572 100644 --- a/test/hello.go +++ b/test/hello.go @@ -5,8 +5,8 @@ import ( ) // #include -// char* hello() { return "hello, world\n"; } -// void printhello() { printf(hello()); } +// char* hello() { return "hello, world"; } +// void printhello() { printf("%s\n", hello()); } import "C" func main() { diff --git a/test/hello_test.go b/test/hello_test.go new file mode 100644 index 0000000..4d5e8b2 --- /dev/null +++ b/test/hello_test.go @@ -0,0 +1,11 @@ +package main + +import "testing" + +func TestHello(t *testing.T) { + want := "hello, world" + got := chello() + if got != want { + t.Errorf("expected %q, got %q", want, got) + } +}