From c00996c34ea44b899bb2b4672e61f5bfe187def6 Mon Sep 17 00:00:00 2001 From: Xdng Yng Date: Thu, 12 Sep 2024 10:01:58 -0700 Subject: [PATCH] Disable WORKSPACE for a couple of straggler repo tests Fixes https://github.com/bazelbuild/bazel/issues/23241. Fixes https://github.com/bazelbuild/bazel/issues/23234. Closes #23590. PiperOrigin-RevId: 673893984 Change-Id: I6b790223e0a4c06b07f5e744a18b547a2ffee76f --- .../shell/bazel/check_external_files_test.sh | 41 ++++++++++--------- .../shell/bazel/external_integration_test.sh | 27 ++++-------- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/test/shell/bazel/check_external_files_test.sh b/src/test/shell/bazel/check_external_files_test.sh index 5af97d33215e6a..7e0f37ccfd5896 100755 --- a/src/test/shell/bazel/check_external_files_test.sh +++ b/src/test/shell/bazel/check_external_files_test.sh @@ -56,9 +56,6 @@ if "$is_windows"; then export MSYS2_ARG_CONV_EXCL="*" fi -# TODO: https://github.com/bazelbuild/bazel/issues/23241 -disable_bzlmod - function get_extrepourl() { if $is_windows; then echo "file:///$(cygpath -m $1)" @@ -81,8 +78,8 @@ setup_remote() { mkdir main cd main - cat >> "WORKSPACE" < $(setup_module_dot_bazel) < BUILD ) mkdir main cd main - cat >> "WORKSPACE" < $(setup_module_dot_bazel) <& "$TEST_log" || fail "Expected build to succeed" - echo "broken file" > bazel-main/external/remote/BUILD + echo "broken file" > bazel-main/external/+_repo_rules+remote/BUILD # The --noexperimental_check_external_repository_files flag doesn't notice the file is broken bazel build --noexperimental_check_external_repository_files @remote//:g >& "$TEST_log" || fail "Expected build to succeed" bazel build @remote//:g >& "$TEST_log" && fail "Expected build to fail" || true - expect_log "no such target '@@remote//:g'" + expect_log "no such target '@@+_repo_rules+remote//:g'" } test_check_all_flags_fast() { @@ -133,7 +130,7 @@ test_check_all_flags_fast() { instances=$(grep -c "$msg" "$(bazel info server_log)") [[ $instances -eq 1 ]] || fail "Should have only been 1 instance, got $instances" - echo "broken file" > bazel-main/external/remote/BUILD + echo "broken file" > bazel-main/external/+_repo_rules+remote/BUILD bazel build \ --noexperimental_check_external_repository_files \ @@ -159,7 +156,7 @@ run_local_repository_isnt_affected() { $extra_args \ @local_rep//:g >& "$TEST_log" && fail "Expected build to fail" || true bazel build --noexperimental_check_external_repository_files @local_rep//:g >& "$TEST_log" && fail "Expected build to fail" || true - expect_log "no such target '@@local_rep//:g'" + expect_log "no such target '@@+_repo_rules+local_rep//:g'" } test_local_repository_isnt_affected() { @@ -175,11 +172,18 @@ run_override_repository_isnt_affected() { shift setup_local - echo > WORKSPACE + # intentionally put a wrong path in MODULE.bazel + cat > "MODULE.bazel" <& "$TEST_log" && fail "Expected build to fail" || true - expect_log "no such package '@@local_rep//'" + expect_log "but it does not exist or is not a directory" - argv="--override_repository=local_rep=$(pwd)/../local_rep" + argv="--override_repository=+_repo_rules+local_rep=$(pwd)/../local_rep" bazel build "$argv" $extra_args @local_rep//:g >& "$TEST_log" || fail "Expected build to succeed" echo "broken file" > ../local_rep/BUILD @@ -189,7 +193,7 @@ run_override_repository_isnt_affected() { "$argv" \ $extra_args \ @local_rep//:g >& "$TEST_log" && fail "Expected build to fail" || true - expect_log "no such target '@@local_rep//:g'" + expect_log "no such target '@@+_repo_rules+local_rep//:g'" } test_override_repository_isnt_affected() { @@ -207,7 +211,6 @@ test_no_fetch_then_fetch() { --noexperimental_check_output_files \ --watchfs \ @remote//:g >& "$TEST_log" && fail "Expected build to fail" || true - expect_log "no such package" expect_log "fetching repositories is disabled" bazel build \ --fetch \ @@ -225,7 +228,7 @@ test_no_build_doesnt_break_the_cache() { --noexperimental_check_output_files \ --watchfs \ @remote//:g >& "$TEST_log" || fail "Expected build to pass" - [[ ! -f bazel-main/external/remote/BUILD ]] || fail "external files shouldn't have been made" + [[ ! -f bazel-main/external/+_repo_rules+remote/BUILD ]] || fail "external files shouldn't have been made" bazel build \ --noexperimental_check_external_repository_files \ --noexperimental_check_output_files \ @@ -236,7 +239,7 @@ test_no_build_doesnt_break_the_cache() { test_symlink_outside_still_checked() { mkdir main cd main - touch WORKSPACE + setup_module_dot_bazel echo 'sh_test(name = "symlink", srcs = ["symlink.sh"])' > BUILD mkdir ../foo diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index e61a2275eb141b..54c02154e8930d 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -454,11 +454,8 @@ function test_deferred_download_two_parallel_downloads() { startup_server "${server_dir}" - # TODO: https://github.com/bazelbuild/bazel/issues/23234 - # This test hangs after moving to MODULE.bazel - cat > WORKSPACE <<'EOF' -load("defer.bzl", "defer") - + cat > $(setup_module_dot_bazel) <<'EOF' +defer = use_repo_rule("//:defer.bzl", "defer") defer(name="defer") EOF @@ -491,7 +488,7 @@ EOF touch BUILD # Start Bazel - bazel query --enable_workspace @defer//:all >& $TEST_log & + bazel query @defer//:all >& $TEST_log & local bazel_pid=$! # Wait until the .download() calls return @@ -515,11 +512,8 @@ EOF } function test_deferred_download_error() { - # TODO: https://github.com/bazelbuild/bazel/issues/23234 - # This test hangs after moving to MODULE.bazel - cat > WORKSPACE <<'EOF' -load("//:defer.bzl", "defer") - + cat > $(setup_module_dot_bazel) <<'EOF' +defer = use_repo_rule("//:defer.bzl", "defer") defer(name="defer") EOF @@ -532,7 +526,6 @@ def _defer_impl(rctx): deferred.wait() print("survived wait") - rctx.file("WORKSPACE", "") rctx.file("BUILD", "filegroup(name='f', srcs=glob(['**']))") defer = repository_rule(implementation = _defer_impl) @@ -541,7 +534,7 @@ EOF touch BUILD # Start Bazel - bazel query --enable_workspace @defer//:all >& $TEST_log && fail "Bazel unexpectedly succeeded" + bazel query @defer//:all >& $TEST_log && fail "Bazel unexpectedly succeeded" expect_log "Error downloading.*doesnotexist" expect_not_log "survived wait" } @@ -560,10 +553,8 @@ function test_deferred_download_smoke() { startup_server "${server_dir}" - # TODO: https://github.com/bazelbuild/bazel/issues/23234 - # This test hangs after moving to MODULE.bazel - cat > WORKSPACE <<'EOF' -load("defer.bzl", "defer") + cat > $(setup_module_dot_bazel) <<'EOF' +defer = use_repo_rule("//:defer.bzl", "defer") defer(name="defer") EOF @@ -587,7 +578,7 @@ EOF touch BUILD # Start Bazel - bazel query --enable_workspace @defer//:all-targets >& $TEST_log & + bazel query @defer//:all-targets >& $TEST_log & local bazel_pid=$! # Wait until the .download() call returns