diff options
author | 2018-01-24 03:12:42 -0800 | |
---|---|---|
committer | 2018-01-24 03:14:30 -0800 | |
commit | c815a2b66d4b650fa8b1c3862970baa791516864 (patch) | |
tree | 4e8c01d66bd04d0c0cf42ab0b5ea343a2bc26311 | |
parent | 444fc9fb7b3d967cb392c8a11a0240892aadb2d6 (diff) |
http_archive: demonstrate that query works offline
Add a test verifying that http_archive from @bazel_tools caches
repositories, also for subsequent queries. Provides a workaround
for #2780.
Change-Id: Ie842c2abf47f42f75e146e454be4ab52efd12ada
PiperOrigin-RevId: 183063093
-rwxr-xr-x | src/test/shell/bazel/external_integration_test.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index 798a66e4ec..4213a3af46 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -1048,4 +1048,49 @@ EOF } +function test_query_cached() { + # Verify that external repositories are cached after being used once. + 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 + EXTREPODIR=`pwd` + rm -f ext.zip + zip ext.zip ext/* + rm -rf ext + + 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://${EXTREPODIR}/ext.zip"], +) +EOF + bazel build '@ext//:bar' || fail "expected sucess" + + # Simulate going offline by removing the external archive + rm -f "${EXTREPODIR}/ext.zip" + bazel query 'deps("@ext//:bar")' > "${TEST_log}" 2>&1 \ + || fail "expected success" + expect_log '@ext//:foo' + bazel shutdown + bazel query 'deps("@ext//:bar")' > "${TEST_log}" 2>&1 \ + || fail "expected success" + expect_log '@ext//:foo' +} + run_suite "external tests" |