diff options
author | Lukacs Berki <lberki@google.com> | 2015-08-24 14:44:59 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2015-08-25 07:39:54 +0000 |
commit | ed5955c5a16996a3b630d7f95206d67d0d0c6380 (patch) | |
tree | 7dc09ecf322a9ac33e3288623c0a6c234db2c87f /src/test/shell/bazel/local_repository_test.sh | |
parent | 29c43874c05ec6a8365661c428b3a0639c8863fb (diff) |
Make Bazel handle visibility through //external: labels correctly: //external: targets can depend on anything and visibility is checked a the edges incoming to said labels.
Fixes #388.
--
MOS_MIGRATED_REVID=101363086
Diffstat (limited to 'src/test/shell/bazel/local_repository_test.sh')
-rwxr-xr-x | src/test/shell/bazel/local_repository_test.sh | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/src/test/shell/bazel/local_repository_test.sh b/src/test/shell/bazel/local_repository_test.sh index e3f146044d..4629ae337e 100755 --- a/src/test/shell/bazel/local_repository_test.sh +++ b/src/test/shell/bazel/local_repository_test.sh @@ -636,7 +636,12 @@ function test_output_file_in_local_repository() { mkdir $r touch $r/WORKSPACE cat > $r/BUILD <<'EOF' -genrule(name="r", srcs=[], outs=["r.out"], cmd="touch $@") +genrule( + name="r", + srcs=[], + outs=["r.out"], + cmd="touch $@", + visibility=["//visibility:public"]) EOF cat > WORKSPACE <<EOF @@ -698,4 +703,64 @@ EOF assert_contains "abcxyz" bazel-bin/x.sh } +function test_visibility_through_bind() { + local r=$TEST_TMPDIR/r + rm -fr $r + mkdir $r + + cat > $r/BUILD <<EOF +genrule( + name = "public", + srcs = ["//external:public"], + outs = ["public.out"], + cmd = "cp \$< \$@", +) + +genrule( + name = "private", + srcs = ["//external:private"], + outs = ["private.out"], + cmd = "cp \$< \$@", +) +EOF + + cat > WORKSPACE <<EOF +local_repository( + name = "r", + path = "$r", +) + +bind( + name = "public", + actual = "//:public", +) + +bind( + name = "private", + actual = "//:private", +) +EOF + + cat > BUILD <<EOF +genrule( + name = "public", + srcs = [], + outs = ["public.out"], + cmd = "echo PUBLIC > \$@", + visibility = ["//visibility:public"], +) + +genrule( + name = "private", + srcs = [], + outs = ["private.out"], + cmd = "echo PRIVATE > \$@", +) +EOF + + bazel build @r//:public >& $TEST_log || fail "failed to build public target" + bazel build @r//:private >& $TEST_log && fail "could build private target" + expect_log "Target '//:private' is not visible from target '@r//:private'" +} + run_suite "local repository tests" |