From 58711715490f740193c6b04989ea651b33b223be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 3 Feb 2022 22:38:43 +0200 Subject: [PATCH] run bazel test This simplifies the tests somewhat. --- .build.yml | 7 ++--- ci/test | 77 +++++++++++++++++------------------------------------- 2 files changed, 26 insertions(+), 58 deletions(-) diff --git a/.build.yml b/.build.yml index df40ffd..b860cd6 100644 --- a/.build.yml +++ b/.build.yml @@ -1,8 +1,8 @@ image: debian/stable packages: - direnv - - file - shellcheck + - qemu-user sources: - https://git.sr.ht/~motiejus/bazel-zig-cc environment: @@ -19,12 +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' - test_hello_on_toolchains: | cd bazel-zig-cc - ./ci/test + ./ci/test --color=yes --curses=yes diff --git a/ci/test b/ci/test index f727a8d..ba48f4f 100755 --- a/ci/test +++ b/ci/test @@ -1,65 +1,36 @@ #!/bin/bash set -euo pipefail + cd "$(dirname "$0")/.." . .envrc -_build_and_file() { - file "$(bazel run --color=yes --curses=yes --run_under=echo "$@")" | \ - tee /dev/stderr -} - _run() { + >&2 echo >&2 echo " $*" + >&2 echo "$@" } -_build() { - local name=$1 - local glob=$2 - shift; shift; - >&2 echo "================================================================" - >&2 echo "Building everything under //test/... for $name" - >&2 echo - _run bazel build --color=yes --curses=yes "$@" //test/... - >&2 echo - >&2 echo "Testing $name and looking for '$glob':" - >&2 echo - if _run _build_and_file "$@" //test/go:go | grep -q "$glob"; then - >&2 echo "OK $name" - return 0 - else - >&2 echo "FAIL $name: glob does not match" - return 1 +while read -r action platform toolchain run_under; do + args=("$@") + if [[ $run_under != : ]]; then + args+=(--run_under="$run_under") fi -} + args+=(--platforms "@zig_sdk//:${platform}_platform") + args+=(--extra_toolchains "@zig_sdk//:${toolchain}_toolchain") + args+=(//test/...) + _run bazel "$action" "${args[@]}" +done <`. -# see https://github.com/ziglang/zig/issues/10299#issuecomment-989595215 -#_build "darwin_arm64" \ -# "Mach-O 64-bit arm64 executable" \ -# --platforms @zig_sdk//:darwin_arm64_platform - -_build "linux_amd64_gnu" \ - "ELF 64-bit.* x86-64.* dynamically linked" \ - --platforms @zig_sdk//:linux_amd64_platform - -_build "linux_amd64_musl" \ - "ELF 64-bit.* x86-64.* statically linked" \ - --platforms @zig_sdk//:linux_amd64_platform \ - --extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain - -_build "linux_arm64_gnu" \ - "ELF 64-bit.* ARM aarch64.* dynamically linked" \ - --platforms @zig_sdk//:linux_arm64_platform - -_build "linux_arm64_musl" \ - "ELF 64-bit.* ARM aarch64.* statically linked" \ - --platforms @zig_sdk//:linux_arm64_platform \ - --extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain +# TODO: +# works locally, fails on srht: +# test linux_arm64 linux_arm64_musl qemu-aarch64 +# +# fails locally, qemu-aarch64 can't find the files in /usr +# test linux_arm64 linux_arm64_gnu.2.28 qemu-aarch64 -L /usr/aarch64-linux-gnu