diff options
author | 2018-01-17 08:58:41 -0800 | |
---|---|---|
committer | 2018-01-17 09:00:55 -0800 | |
commit | 8b459d77bca8cbff5edd8a4e1715aa6870f88eff (patch) | |
tree | 2e7563f57c6ee39decf3fbc62feff0a14f1b51e9 | |
parent | 8134b9fc140c810d00a91ca9a0313a1e4322ee00 (diff) |
Demontrate that http_archive can pick up a missing build file
The http_archive command from @bazel_tools can add a BUILD file to an
external repository. Add a test ensuring that changes to that file, in
particular the addition of a previously missing file, are tracked
properly.
Provides a workaround for #3637.
Change-Id: Ibd6a3336834686a13eaa1f9ce7d4c6223410b222
PiperOrigin-RevId: 182221653
-rwxr-xr-x | src/test/shell/bazel/external_integration_test.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index a899c1183d..49b9471857 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -925,6 +925,7 @@ function test_same_name() { zip ext.zip ext/* rm -rf ext + rm -rf main mkdir main cd main cat > WORKSPACE <<EOF @@ -948,4 +949,53 @@ EOF || fail 'Expected @ext//:foo and //:foo not to conflict' } +function test_missing_build() { + mkdir ext + echo foo> ext/foo + EXTREPODIR=`pwd` + 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"], + build_file="@//:ext.BUILD", +) +EOF + cat > BUILD <<'EOF' +genrule( + name = "localfoo", + srcs = ["@ext//:foo"], + outs = ["foo"], + cmd = "cp $< $@", +) +EOF + bazel build //:localfoo && fail 'Expected failure' || : + + cat > ext.BUILD <<'EOF' +exports_files(["foo"]) +EOF + + bazel build //:localfoo || fail 'Expected success' + + # Changes to the BUILD file in the external repository should be tracked + rm -f ext.BUILD && touch ext.BUILD + + bazel build //:localfoo && fail 'Expected failure' || : + + # Verify that we don't call out unconditionally + cat > ext.BUILD <<'EOF' +exports_files(["foo"]) +EOF + bazel build //:localfoo || fail 'Expected success' + rm -f "${EXTREPODIR}/ext.zip" + bazel build //:localfoo || fail 'Expected success' +} + run_suite "external tests" |