diff options
author | Klaus Aehlig <aehlig@google.com> | 2018-02-09 01:53:43 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-09 01:55:37 -0800 |
commit | 88374614b62b17587453137814d264fdaf7bd70e (patch) | |
tree | ac82f27567a7d528bfe92a2222280d309c82c036 /src/test/shell | |
parent | aa79fd483daff0db9be274c33de109257f8a6804 (diff) |
Support local search for http archives
With --experimental_repository_cache, bazel has means of avoiding
downloading the same archive again. However, this requires bazel
to first download it itself, as we make no guarantee about the
internal structure of that cache; this, in turn, does not play
well in situations where bazel has to cooperate with other tools,
e.g., because the bazel build is just one step in a larger package
building process. Therefore, add an experimental option allowing
to specify directories where the outer process may have placed
needed files and make bazel not download them if a file with correct
name and hash could be found in one of those directories. In this
way, cooperation is possible without patching all entries in the
WORSPACE file.
Change-Id: I43240b8b59bf8472ec0310661015899e46491236
PiperOrigin-RevId: 185115713
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/external_integration_test.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index b5c5f844b6..cc3b18a21b 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -1168,6 +1168,50 @@ EOF expect_log '@ext//:foo' } +function test_distdir() { + WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX") + cd "${WRKDIR}" + mkdir ext + cat > ext/BUILD <<'EOF' +genrule( + name="foo", + outs=["foo.txt"], + cmd="echo Hello World > $@", + visibility = ["//visibility:public"], +) +EOF + zip ext.zip ext/* + rm -rf ext + sha256=$(sha256sum ext.zip | head -c 64) + + mkdir distfiles + mv ext.zip distfiles + + 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=["http://doesnotexist.example.com/outdatedpath/ext.zip"], + sha256="${sha256}", +) +EOF + cat > BUILD <<'EOF' +genrule( + name = "local", + srcs = ["@ext//:foo"], + outs = ["local.txt"], + cmd = "cp $< $@", +) +EOF + + bazel clean --expunge + bazel build --experimental_distdir="${WRKDIR}/distfiles" //:local \ + || fail "expected success" +} + function test_good_symlinks() { WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX") cd "${WRKDIR}" |