From 157caed02ef354447f673c89c6a0e296bae5341c Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 9 Feb 2018 03:13:28 -0800 Subject: experimental_repository_cache: support relative paths ...and interpret them relative to the workspace directory. Improves on #3516. In fact, fixes the original request of supporting relative paths. Change-Id: Ibbb6fd43179d589ad477427e47e26c773c7a04de PiperOrigin-RevId: 185121629 --- src/test/shell/bazel/BUILD | 2 +- src/test/shell/bazel/external_integration_test.sh | 73 +++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) (limited to 'src/test/shell') diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index a376914e49..3df2ee2bb3 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -238,7 +238,7 @@ sh_test( size = "large", srcs = ["external_integration_test.sh"], data = [":test-deps"], - shard_count = 6, + shard_count = 12, ) sh_test( diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index cc3b18a21b..0cbc64c2c7 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -1095,6 +1095,79 @@ EOF expect_log '@ext//:foo' } +function test_repository_cache_relative_path() { + # Verify that --experimental_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") + 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 cache + mkdir cache + + rm -rf main + mkdir main + cd main + cat > WORKSPACE < "${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 < "${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. -- cgit v1.2.3