diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index e0fd5e41ff..2c60bc57e2 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -630,13 +630,13 @@ tasks: name: bzlmod BCR presubmit platform: ubuntu2004 working_directory: examples/bzlmod/hello_world - build_targets: + test_targets: - "//..." macos_bzlmod_bcr: name: bzlmod BCR presubmit platform: macos working_directory: examples/bzlmod/hello_world - build_targets: + test_targets: - "//..." buildifier: diff --git a/examples/bzlmod/hello_world/BUILD.bazel b/examples/bzlmod/hello_world/BUILD.bazel index 8f3739b145..d1b318d966 100644 --- a/examples/bzlmod/hello_world/BUILD.bazel +++ b/examples/bzlmod/hello_world/BUILD.bazel @@ -16,7 +16,7 @@ sh_test( name = "hello_world_test", srcs = ["hello_world_test.sh"], args = [ - "$(rootpath :hello_world)", + "$(rlocationpath :hello_world)", ], data = [ ":hello_world", diff --git a/examples/bzlmod/hello_world/hello_world_test.sh b/examples/bzlmod/hello_world/hello_world_test.sh index ca39635587..f0efdf02ca 100755 --- a/examples/bzlmod/hello_world/hello_world_test.sh +++ b/examples/bzlmod/hello_world/hello_world_test.sh @@ -1,5 +1,19 @@ #!/usr/bin/env bash +# --- begin runfiles.bash initialization v3 --- +# Copy-pasted from the Bazel Bash runfiles library v3. +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v3 --- + + +set -euo pipefail + # MARK - Functions fail() { @@ -12,10 +26,10 @@ fail() { if [[ "$#" -ne 1 ]]; then fail "Usage: $0 /path/to/hello_world" fi -hello_world="$1" +HELLO_WORLD="$(rlocation "$1")" # MARK - Test -output="$( "${hello_world}" )" -[[ "${output}" == "Hello, world!" ]] || \ - fail 'Expected "Hello, world!", but was' "${output}" +OUTPUT="$("${HELLO_WORLD}")" +[[ "${OUTPUT}" == "Hello, world!" ]] || + fail 'Expected "Hello, world!", but was' "${OUTPUT}"