1

Merge branch 'tests'

This commit is contained in:
Motiejus Jakštys 2022-02-03 15:47:45 +02:00
commit 3e77c48662
5 changed files with 18 additions and 18 deletions

View File

@ -168,9 +168,9 @@ may apply to aarch64, but the author didn't find a need to test it (yet).
## linux cgo + glibc 2.28 ## linux cgo + glibc 2.28
``` ```
$ bazel build --platforms @zig_sdk//:linux_amd64_platform //test:hello $ bazel build --platforms @zig_sdk//:linux_amd64_platform //test/go:go
$ file bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/hello_/hello $ file bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go
bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/hello_/hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, Go BuildID=redacted, with debug_info, not stripped bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, Go BuildID=redacted, with debug_info, not stripped
``` ```
## linux cgo + musl ## linux cgo + musl
@ -178,21 +178,21 @@ bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/hello_/hello: ELF 64-bit LSB exe
``` ```
$ bazel build \ $ bazel build \
--platforms @zig_sdk//:linux_amd64_platform \ --platforms @zig_sdk//:linux_amd64_platform \
--extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain //test:hello --extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain //test/go:go
... ...
$ file ../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/hello_/hello $ file bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go
../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/hello_/hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, with debug_info, not stripped bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, stripped
$ ../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/hello_/hello $ bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go
hello, world hello, world
``` ```
## macos cgo ## macos cgo
``` ```
$ bazel build --platforms @zig_sdk//:darwin_amd64_platform //test:hello $ bazel build --platforms @zig_sdk//:darwin_amd64_platform //test/go:go
... ...
$ file bazel-bin/test/hello_/hello $ file bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go
bazel-bin/test/hello_/hello: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE> bazel-out/k8-opt-ST-d17813c235ce/bin/test/go/go_/go: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE|HAS_TLV_DESCRIPTORS>
``` ```
## Transient docker environment ## Transient docker environment

View File

@ -21,9 +21,9 @@ _test() {
>&2 echo >&2 echo
>&2 echo "Testing $name and looking for '$glob':" >&2 echo "Testing $name and looking for '$glob':"
>&2 echo >&2 echo
>&2 echo " bazel build $* //test:test" >&2 echo " bazel build $* //test/go:go"
>&2 echo >&2 echo
if _build_and_file "$@" //test:test | grep -q "$glob"; then if _build_and_file "$@" //test/go:go | grep -q "$glob"; then
>&2 echo "OK $name" >&2 echo "OK $name"
return 0 return 0
else else

View File

@ -2,22 +2,22 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//rules:rules_go.bzl", "go_binary") load("//rules:rules_go.bzl", "go_binary")
go_library( go_library(
name = "test_lib", name = "go_lib",
srcs = ["hello.go"], srcs = ["hello.go"],
cgo = True, cgo = True,
importpath = "git.sr.ht/~motiejus/bazel-zig-cc/test", importpath = "git.sr.ht/~motiejus/bazel-zig-cc/test/go",
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
) )
go_binary( go_binary(
name = "test", name = "go",
embed = [":test_lib"], embed = [":go_lib"],
static = "on", static = "on",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
go_test( go_test(
name = "test_test", name = "go_test",
srcs = ["hello_test.go"], srcs = ["hello_test.go"],
embed = [":test_lib"], embed = [":go_lib"],
) )