From f88bd2d4446b359e113899d0e746ee7ec140f23b Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Tue, 19 Sep 2023 16:39:42 +0200 Subject: [PATCH] Ignore the default when local repository_cache is used. --- .../devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java | 3 +++ src/test/py/bazel/test_base.py | 3 +++ src/test/shell/bazel/bazel_bootstrap_distfile_test.sh | 4 +++- src/test/shell/testenv.sh.tmpl | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java b/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java index a226e8771c014a..8a4bef13988adc 100644 --- a/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java +++ b/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java @@ -78,6 +78,9 @@ public void setup(BlackBoxTestContext context) throws IOException { String sharedRepoCache = System.getenv("REPOSITORY_CACHE"); if (sharedRepoCache != null) { lines.add("common --repository_cache=" + sharedRepoCache); + // TODO(sluongng): Remove this flag once all dependencies are mirrored. + // See https://github.com/bazelbuild/bazel/pull/19549 for more context. + lines.add("common --norepository_cache_urls_as_default_canonical_id"); if (OS.getCurrent() == OS.DARWIN) { // For reducing SSD usage on our physical Mac machines. lines.add("common --experimental_repository_cache_hardlinks"); diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index 334828f250d0a4..24c60f900eeb4c 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -127,6 +127,9 @@ def setUp(self): shared_repo_cache = os.environ.get('REPOSITORY_CACHE') if shared_repo_cache: f.write('common --repository_cache={}\n'.format(shared_repo_cache)) + # TODO(sluongng): Remove this flag once all dependencies are mirrored. + # See https://github.com/bazelbuild/bazel/pull/19549 for more context. + f.write('common --norepository_cache_urls_as_default_canonical_id\n') if TestBase.IsDarwin(): # For reducing SSD usage on our physical Mac machines. f.write('common --experimental_repository_cache_hardlinks\n') diff --git a/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh b/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh index 5d6456e09dc507..297ecacb5d922d 100755 --- a/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh +++ b/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh @@ -102,7 +102,9 @@ function test_bootstrap() { JAVABASE=$(echo reduced*) - env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" ./compile.sh \ + # TODO: remove `norepository_cache_urls_as_default_canonical_id` once all dependencies are mirrored. + # See https://github.com/bazelbuild/bazel/pull/19549 for more context. + env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk --norepository_cache_urls_as_default_canonical_id" ./compile.sh \ || fail "Expected to be able to bootstrap bazel" ./output/bazel \ --server_javabase=$JAVABASE --host_jvm_args=--add-opens=java.base/java.nio=ALL-UNNAMED \ diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index a77b67ee9ddcfb..7518f8f2e559d9 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -324,6 +324,9 @@ EOF if [[ -n ${REPOSITORY_CACHE:-} ]]; then echo "testenv.sh: Using repository cache at $REPOSITORY_CACHE." echo "common --repository_cache=$REPOSITORY_CACHE" >> $TEST_TMPDIR/bazelrc + # TODO(sluongng): Remove this flag once all dependencies are mirrored. + # See https://github.com/bazelbuild/bazel/pull/19549 for more context. + echo "common --norepository_cache_urls_as_default_canonical_id" >> $TEST_TMPDIR/bazelrc if is_darwin; then # For reducing SSD usage on our physical Mac machines. echo "testenv.sh: Enabling --experimental_repository_cache_hardlinks"