Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure bzlmod example tests are run #2371

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/bzlmod/hello_world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sh_test(
name = "hello_world_test",
srcs = ["hello_world_test.sh"],
args = [
"$(rootpath :hello_world)",
"$(rlocationpath :hello_world)",
illicitonion marked this conversation as resolved.
Show resolved Hide resolved
],
data = [
":hello_world",
Expand Down
22 changes: 18 additions & 4 deletions examples/bzlmod/hello_world/hello_world_test.sh
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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}"
Loading