diff options
author | Klaus Aehlig <aehlig@google.com> | 2018-02-27 07:22:07 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-27 07:23:36 -0800 |
commit | 6e0933886d3c6b7f68075da4bdb08500ce2b6f86 (patch) | |
tree | 9f154446d7b4ea3335b50ec5963a7639d7fa98c4 /src/test/shell/bazel/external_integration_test.sh | |
parent | db80298391bd953b1a1f8e9bb83c2d4c2f3747b4 (diff) |
Make repository_chache non-experimental and enable by default
Make the --experimental_repository_cache option no longer experimental and enable
the cache by default. The default location is in the a separate directory under the
install base (under .cache/bazel user's home directory); this means it is shared
between workspaces und not between different versions of bazel. We plan to also
share it between different bazel versions in the future.
Fixes #4676.
RELNOTES:
repository_cache is no longer experimental and enabled by default.
Change-Id: I8499c2d1811e0fe8d830796e07cd6f8bc75e48ba
PiperOrigin-RevId: 187172766
Diffstat (limited to 'src/test/shell/bazel/external_integration_test.sh')
-rwxr-xr-x | src/test/shell/bazel/external_integration_test.sh | 73 |
1 files changed, 69 insertions, 4 deletions
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index 9356fd8e75..e948e14754 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -1105,7 +1105,7 @@ EOF } function test_repository_cache_relative_path() { - # Verify that --experimental_repository_cache works for query and caches soly + # Verify that --repository_cache works for query and caches soly # based on the predicted hash, for a repository-cache location given as path # relative to the WORKSPACE WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX") @@ -1144,7 +1144,7 @@ http_archive( ) EOF # Use the external repository once to make sure it is cached. - bazel build --experimental_repository_cache="../cache" '@ext//:bar' \ + bazel build --repository_cache="../cache" '@ext//:bar' \ || fail "expected sucess" # Now "go offline" and clean local resources. @@ -1154,7 +1154,7 @@ EOF # The value should still be available from the repository cache bazel query 'deps("@ext//:bar")' \ - --experimental_repository_cache="../cache" > "${TEST_log}" \ + --repository_cache="../cache" > "${TEST_log}" \ || fail "Expected success" expect_log '@ext//:foo' @@ -1172,11 +1172,76 @@ http_archive( ) EOF bazel query 'deps("@ext//:bar")' \ - --experimental_repository_cache="../cache" > "${TEST_log}" \ + --repository_cache="../cache" > "${TEST_log}" \ || fail "Expected success" expect_log '@ext//:foo' } +test_default_cache() +{ + # Verify that the default cache works for query and caches soly + # based on the predicted hash, for a repository-cache location given as path + # relative to the WORKSPACE + WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX") + cd "${WRKDIR}" + mkdir ext + cat > ext/BUILD <<'EOF' +genrule( + name="foo", + outs=["foo.txt"], + cmd="echo Hello World > $@", +) +genrule( + name="bar", + outs=["bar.txt"], + srcs=[":foo"], + cmd="cp $< $@", +) +EOF + zip ext.zip ext/* + rm -rf ext + sha256=$(sha256sum ext.zip | head -c 64) + + rm -rf main + mkdir main + cd main + cat > WORKSPACE <<EOF +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name="ext", + strip_prefix="ext", + urls=["file://${WRKDIR}/ext.zip"], + sha256="${sha256}", +) +EOF + # Use the external repository once to make sure it is cached. + bazel build '@ext//:bar' || fail "expected sucess" + + # Now "go offline" and clean local resources. + rm -f "${WRKDIR}/ext.zip" + bazel clean --expunge + + # The value should still be available from the repository cache + bazel query 'deps("@ext//:bar")' > "${TEST_log}" || fail "Expected success" + expect_log '@ext//:foo' + + # Clean again. + bazel clean --expunge + # Even with a different source URL, the cache sould be consulted. + + cat > WORKSPACE <<EOF +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name="ext", + strip_prefix="ext", + urls=["http://doesnotexist.example.com/invalidpath/othername.zip"], + sha256="${sha256}", +) +EOF + bazel query 'deps("@ext//:bar")' > "${TEST_log}" || fail "Expected success" + expect_log '@ext//:foo' +} + function test_repository_cache() { # Verify that --experimental_repository_cache works for query and caches soly # based on the predicted hash. |