Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy committed Oct 10, 2023
1 parent b79483e commit 8bd923b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ filegroup(
visibility = [
"//src/main/starlark/tests/builtins_bzl:__subpackages__",
"//src/test/shell:__subpackages__",
"//src/test/tools/bzlmod:__subpackages__",
],
)

Expand Down
4 changes: 3 additions & 1 deletion src/test/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ package(

filegroup(
name = "srcs",
srcs = glob(["**"]),
srcs = glob(["**"]) + [
"//src/test/tools/bzlmod:srcs",
],
visibility = ["//src:__subpackages__"],
)

Expand Down
10 changes: 9 additions & 1 deletion src/test/tools/bzlmod/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
exports_files(["MODULE.bazel.lock"])

filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = ["//src:__subpackages__"],
)

# To avoid accessing BCR in most tests, we generate and checkin a default MODULE.bazel.lock
# file in an empty workspace that will be used in integration tests setup.
sh_binary(
Expand All @@ -14,7 +20,9 @@ sh_test(
srcs = ["verify_default_lock_file.sh"],
deps = ["@bazel_tools//tools/bash/runfiles"],
data = [
"//src/test/shell/bazel:test-deps",
"//src:bazel",
":MODULE.bazel.lock",
]
],
tags = ["requires-network"],
)
17 changes: 7 additions & 10 deletions src/test/tools/bzlmod/verify_default_lock_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---

function verify_lock_file() {
tmpdir=$(mktemp -d -t bazel.XXXXXX)
trap 'cleanup $tmpdir' EXIT
echo "$tmpdir"
source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }

cd "${tmpdir}"
function test_verify_lock_file() {
touch WORKSPACE
rm -f MODULE.bazel
cp $(rlocation io_bazel/src/test/tools/bzlmod/MODULE.bazel.lock) MODULE.bazel.lock

bazel=$(rlocation io_bazel/src/bazel)
echo "Running: $bazel mod deps --lockfile_mode=error"
$bazel mod deps --lockfile_mode=error
echo "Running: bazel mod deps --lockfile_mode=error" >& "$TEST_log"
bazel mod deps --lockfile_mode=error >& "$TEST_log" || fail "Default lock file is not in sync with MODULE.tools. Please run \"bazel run //src/test/tools/bzlmod:update_default_lock_file\""
}

verify_lock_file
run_suite "test_verify_lock_file"

0 comments on commit 8bd923b

Please sign in to comment.